Class XAJmsConsumerAsync
- java.lang.Object
-
- com.adaptris.core.AdaptrisMessageWorkerImp
-
- com.adaptris.core.AdaptrisMessageConsumerImp
-
- com.adaptris.xa.jms.XAJmsConsumerImpl
-
- com.adaptris.xa.jms.XAJmsConsumer
-
- com.adaptris.xa.jms.async.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 AsyncConsumerAwareA JMS consumer that extends the base functionality of theXAJmsConsumerThis differs from the standard
This consumer is designed to work with theXAJmsConsumerby providing support for JMS 2.0 asynchronous callbacks.XAWorkflowAsyncand theXAJmsProducerAsync.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.
-
-
Field Summary
-
Fields inherited from class com.adaptris.xa.jms.XAJmsConsumerImpl
consumeLock, consumer, currentTxId, executor, pollerTask, session
-
Fields inherited from class com.adaptris.core.AdaptrisMessageWorkerImp
log
-
-
Constructor Summary
Constructors Constructor Description XAJmsConsumerAsync()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidbeginTransaction()protected booleancommitTransaction()protected booleancommitTransaction(int messageNumber)protected javax.jms.MessageConsumercreateConsumer()intgetCompletedMessages()java.lang.LonggetMaxWaitForBatchCallbacks()Gets the maximum wait time in milliseconds for each transaction to wait for successful async produced message callbacks.java.lang.LonggetWaitPollIntervalMillis()While waiting for all asynchronous produced message callbacks, this value determines how often, in milliseconds we check all callbacks have been received.java.lang.LongmaxWaitForBatchCallbacks()voidonCompletion(javax.jms.Message message)voidonException(javax.jms.Message message, java.lang.Exception exception)protected voidprocessXAMessages()voidsetCompletedMessages(int completedMessages)voidsetMaxWaitForBatchCallbacks(java.lang.Long maxWaitForBatchCallbacks)Sets the maximum wait time in milliseconds for each transaction to wait for successful async produced message callbacks.voidsetWaitPollIntervalMillis(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.protected java.lang.LongwaitPollIntervalMillis()-
Methods inherited from class com.adaptris.xa.jms.XAJmsConsumerImpl
close, configuredAcknowledgeMode, configuredCorrelationIdSource, configuredMessageListener, configuredMessageTranslator, consumeLocationKey, currentLogger, currentSession, endpoint, getConsumer, getCorrelationIdSource, getEndpoint, getGlobalLock, getMaxBatch, getMaxTransactionTime, getMessageSelector, getMessagesInCurrentTransaction, getMessageTranslator, getOnMessageHandler, getReceiveWait, getRecreateConsumerOnError, getTransactionManager, getXaExceptionHandler, getXaResourceName, globalLock, handleException, handleXAException, init, isEnabled, isManagedTransaction, messageSelector, newThreadName, prepare, rollbackIfRequired, rollbackTimeout, rollbackTransaction, setConsumer, setCorrelationIdSource, setEndpoint, setGlobalLock, setMaxBatch, setMaxTransactionTime, setMessageSelector, setMessagesInCurrentTransaction, setMessageTranslator, setOnMessageHandler, setReceiveWait, setRecreateConsumerOnError, setTransactionManager, setXaExceptionHandler, setXaResourceName, start, startProcessing, stop, withEndpoint
-
Methods inherited from class com.adaptris.core.AdaptrisMessageConsumerImp
changeState, registerAdaptrisMessageListener, renameThread, requestClose, requestInit, requestStart, requestStop, retrieveAdaptrisMessageListener, retrieveComponentState
-
Methods inherited from class com.adaptris.core.AdaptrisMessageWorkerImp
createName, createQualifier, decode, encode, getEncoder, getIsTrackingEndpoint, getMessageFactory, getUniqueId, handleConnectionException, isTrackingEndpoint, registerConnection, registerEncoderMessageFactory, retrieveConnection, setEncoder, setIsTrackingEndpoint, setMessageFactory, setUniqueId, withMessageFactory, withUniqueID
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.adaptris.core.AdaptrisComponent
getUniqueId
-
Methods inherited from interface com.adaptris.core.AdaptrisMessageWorker
decode, encode, getEncoder, getMessageFactory, handleConnectionException, registerConnection, retrieveConnection, setEncoder, setMessageFactory
-
Methods inherited from interface com.adaptris.core.MessageEventGenerator
createName, createQualifier, isTrackingEndpoint
-
-
-
-
Method Detail
-
processXAMessages
protected void processXAMessages()
- Overrides:
processXAMessagesin classXAJmsConsumerImpl
-
commitTransaction
protected boolean commitTransaction(int messageNumber) throws java.lang.Exception- Overrides:
commitTransactionin classXAJmsConsumerImpl- Throws:
java.lang.Exception
-
commitTransaction
protected boolean commitTransaction() throws java.lang.Exception- Overrides:
commitTransactionin classXAJmsConsumerImpl- Throws:
java.lang.Exception
-
onCompletion
public void onCompletion(javax.jms.Message message)
- Specified by:
onCompletionin interfacejavax.jms.CompletionListener
-
onException
public void onException(javax.jms.Message message, java.lang.Exception exception)- Specified by:
onExceptionin interfacejavax.jms.CompletionListener
-
beginTransaction
protected void beginTransaction() throws java.lang.Exception- Overrides:
beginTransactionin classXAJmsConsumerImpl- Throws:
java.lang.Exception
-
createConsumer
protected javax.jms.MessageConsumer createConsumer() throws javax.jms.JMSException, CoreException- Overrides:
createConsumerin classXAJmsConsumer- Throws:
javax.jms.JMSExceptionCoreException
-
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-
-
-