Class XAJmsConsumerAsync

  • All Implemented Interfaces:
    AdaptrisComponent, AdaptrisMessageConsumer, AdaptrisMessageWorker, ComponentLifecycle, ComponentLifecycleExtension, JmsActorConfig, LicensedComponent, MessageEventGenerator, StateManagedComponent, AsyncAware, AsyncConsumerAware, javax.jms.CompletionListener

    @ComponentProfile(summary="Listen for JMS messages on the specified queue or topic, with XA transactions.",
                      tag="consumer,jms,xa,async",
                      recommended=com.adaptris.xa.jms.XAJmsConnection.class)
    public class XAJmsConsumerAsync
    extends XAJmsConsumer
    implements AsyncConsumerAware
    A JMS consumer that extends the base functionality of the XAJmsConsumer

    This differs from the standard XAJmsConsumer by providing support for JMS 2.0 asynchronous callbacks.

    This consumer is designed to work with the XAWorkflowAsync and the XAJmsProducerAsync.

    The async producer will send messages to your JMS endpoint but will not wait for the acknowledgement before continuing. At some point in the future this JMS consumer will receive an notification for each produced message, indicating if the message has indeed been acknowledged or not.

    Once we have consumed/processed the max-batch number of messages, we will then wait for all successful notifications before committing the transaction. Should any of the notifications come back as an error, we will rollback the entire transaction. Additionally if we wait longer than the configured max-wait-for-batch-callbacks before receiving all successful notifications, then again the entire transaction is rolled back.

    In the adapter configuration file this class is aliased as xa-jms-consumer-async which is the preferred alternative to the fully qualified classname when building your configuration.

    • Constructor Detail

      • XAJmsConsumerAsync

        public XAJmsConsumerAsync()
    • Method Detail

      • commitTransaction

        protected boolean commitTransaction​(int messageNumber)
                                     throws java.lang.Exception
        Overrides:
        commitTransaction in class XAJmsConsumerImpl
        Throws:
        java.lang.Exception
      • commitTransaction

        protected boolean commitTransaction()
                                     throws java.lang.Exception
        Overrides:
        commitTransaction in class XAJmsConsumerImpl
        Throws:
        java.lang.Exception
      • onCompletion

        public void onCompletion​(javax.jms.Message message)
        Specified by:
        onCompletion in interface javax.jms.CompletionListener
      • onException

        public void onException​(javax.jms.Message message,
                                java.lang.Exception exception)
        Specified by:
        onException in interface javax.jms.CompletionListener
      • beginTransaction

        protected void beginTransaction()
                                 throws java.lang.Exception
        Overrides:
        beginTransaction in class XAJmsConsumerImpl
        Throws:
        java.lang.Exception
      • maxWaitForBatchCallbacks

        public java.lang.Long maxWaitForBatchCallbacks()
      • getMaxWaitForBatchCallbacks

        public java.lang.Long getMaxWaitForBatchCallbacks()
        Gets the maximum wait time in milliseconds for each transaction to wait for successful async produced message callbacks.
      • setMaxWaitForBatchCallbacks

        public void setMaxWaitForBatchCallbacks​(java.lang.Long maxWaitForBatchCallbacks)
        Sets the maximum wait time in milliseconds for each transaction to wait for successful async produced message callbacks.
        Parameters:
        maxWaitForBatchCallbacks -
      • getCompletedMessages

        public int getCompletedMessages()
      • setCompletedMessages

        public void setCompletedMessages​(int completedMessages)
      • waitPollIntervalMillis

        protected java.lang.Long waitPollIntervalMillis()
      • getWaitPollIntervalMillis

        public java.lang.Long getWaitPollIntervalMillis()
        While waiting for all asynchronous produced message callbacks, this value determines how often, in milliseconds we check all callbacks have been received.
      • setWaitPollIntervalMillis

        public void setWaitPollIntervalMillis​(java.lang.Long waitPollIntervalMillis)
        While waiting for all asynchronous produced message callbacks, this value determines how often, in milliseconds we check all callbacks have been received.
        Parameters:
        waitPollIntervalMillis -