Class BatchMessageListenerContainer
- java.lang.Object
- org.springframework.jms.support.JmsAccessor
- org.springframework.jms.support.destination.JmsDestinationAccessor
- org.springframework.jms.listener.AbstractJmsListeningContainer
- org.springframework.jms.listener.AbstractMessageListenerContainer
- org.springframework.jms.listener.AbstractPollingMessageListenerContainer
- org.springframework.jms.listener.DefaultMessageListenerContainer
- org.springframework.batch.container.jms.BatchMessageListenerContainer
- All Implemented Interfaces:
org.springframework.beans.factory.Aware
,org.springframework.beans.factory.BeanNameAware
,org.springframework.beans.factory.DisposableBean
,org.springframework.beans.factory.InitializingBean
,org.springframework.context.Lifecycle
,org.springframework.context.Phased
,org.springframework.context.SmartLifecycle
,org.springframework.jms.listener.MessageListenerContainer
public class BatchMessageListenerContainer extends org.springframework.jms.listener.DefaultMessageListenerContainer
Message listener container adapted for intercepting the message reception with advice provided through configuration.
To enable batching of messages in a single transaction, use theTransactionInterceptor
and theRepeatOperationsInterceptor
in the advice chain (with or without a transaction manager set in the base class). Instead of receiving a single message and processing it, the container will then use aRepeatOperations
to receive multiple messages in the same thread. Use with aRepeatOperations
and a transaction interceptor. If the transaction interceptor uses XA then use an XA connection factory, or else theTransactionAwareConnectionFactoryProxy
to synchronize the JMS session with the ongoing transaction (opening up the possibility of duplicate messages after a failure). In the latter case you will not need to provide a transaction manager in the base class - it only gets on the way and prevents the JMS session from synchronizing with the database transaction.- Author:
- Dave Syer
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
BatchMessageListenerContainer.ContainerDelegate
Field Summary
Fields inherited from class org.springframework.jms.listener.DefaultMessageListenerContainer
CACHE_AUTO, CACHE_CONNECTION, CACHE_CONSUMER, CACHE_NONE, CACHE_SESSION, DEFAULT_RECOVERY_INTERVAL, DEFAULT_THREAD_NAME_PREFIX
Fields inherited from class org.springframework.jms.listener.AbstractPollingMessageListenerContainer
DEFAULT_RECEIVE_TIMEOUT
Fields inherited from class org.springframework.jms.listener.AbstractJmsListeningContainer
lifecycleMonitor, sharedConnectionMonitor
Constructor Summary
Constructors Constructor Description BatchMessageListenerContainer()
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
afterPropertiesSet()
Set up interceptor with provided advice on thereceiveAndExecute(Object, Session, MessageConsumer)
method.protected void
handleListenerException(java.lang.Throwable ex)
Override base class to prevent exceptions from being swallowed.void
initializeProxy()
protected boolean
receiveAndExecute(java.lang.Object invoker, javax.jms.Session session, javax.jms.MessageConsumer consumer)
Override base class method to wrap call in advice if provided.void
setAdviceChain(org.aopalliance.aop.Advice[] advices)
Public setter for theAdvice
.Methods inherited from class org.springframework.jms.listener.DefaultMessageListenerContainer
applyBackOffTime, createDefaultTaskExecutor, doInitialize, doRescheduleTask, doShutdown, establishSharedConnection, getActiveConsumerCount, getCacheLevel, getConcurrentConsumers, getIdleConsumerLimit, getIdleTaskExecutionLimit, getMaxConcurrentConsumers, getMaxMessagesPerTask, getScheduledConsumerCount, handleListenerSetupFailure, initialize, isRecovering, isRegisteredWithDestination, messageReceived, noMessageReceived, recoverAfterListenerSetupFailure, refreshConnectionUntilSuccessful, refreshDestination, scheduleNewInvokerIfAppropriate, setBackOff, setCacheLevel, setCacheLevelName, setConcurrency, setConcurrentConsumers, setIdleConsumerLimit, setIdleTaskExecutionLimit, setMaxConcurrentConsumers, setMaxMessagesPerTask, setRecoveryInterval, setTaskExecutor, sharedConnectionEnabled, start, startSharedConnection, stop, stopSharedConnection
Methods inherited from class org.springframework.jms.listener.AbstractPollingMessageListenerContainer
createListenerConsumer, doReceiveAndExecute, getConnection, getReceiveTimeout, getSession, getTransactionManager, isSessionLocallyTransacted, receiveMessage, setReceiveTimeout, setSessionTransacted, setTransactionManager, setTransactionName, setTransactionTimeout, shouldCommitAfterNoMessageReceived
Methods inherited from class org.springframework.jms.listener.AbstractMessageListenerContainer
checkMessageListener, commitIfNecessary, createConsumer, doExecuteListener, doInvokeListener, doInvokeListener, executeListener, getDefaultSubscriptionName, getDestination, getDestinationDescription, getDestinationName, getDurableSubscriptionName, getErrorHandler, getExceptionListener, getMessageConverter, getMessageListener, getMessageSelector, getReplyQosSettings, getSubscriptionName, invokeErrorHandler, invokeExceptionListener, invokeListener, isAcceptMessagesWhileStopping, isExposeListenerSession, isPubSubNoLocal, isReplyPubSubDomain, isSubscriptionDurable, isSubscriptionShared, rollbackIfNecessary, rollbackOnExceptionIfNecessary, setAcceptMessagesWhileStopping, setDestination, setDestinationName, setDurableSubscriptionName, setErrorHandler, setExceptionListener, setExposeListenerSession, setMessageConverter, setMessageListener, setMessageSelector, setPubSubNoLocal, setReplyPubSubDomain, setReplyQosSettings, setSubscriptionDurable, setSubscriptionName, setSubscriptionShared, setupMessageListener, validateConfiguration
Methods inherited from class org.springframework.jms.listener.AbstractJmsListeningContainer
createSharedConnection, destroy, doStart, doStop, getBeanName, getClientId, getPausedTaskCount, getPhase, getSharedConnection, isActive, isAutoStartup, isRunning, logRejectedTask, prepareSharedConnection, refreshSharedConnection, rescheduleTaskIfNecessary, resumePausedTasks, runningAllowed, setAutoStartup, setBeanName, setClientId, setPhase, shutdown, stop
Methods inherited from class org.springframework.jms.support.destination.JmsDestinationAccessor
getDestinationResolver, isPubSubDomain, receiveFromConsumer, resolveDestinationName, setDestinationResolver, setPubSubDomain
Methods inherited from class org.springframework.jms.support.JmsAccessor
convertJmsAccessException, createConnection, createSession, getConnectionFactory, getSessionAcknowledgeMode, isClientAcknowledge, isSessionTransacted, obtainConnectionFactory, setConnectionFactory, setSessionAcknowledgeMode, setSessionAcknowledgeModeName
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Method Detail
setAdviceChain
public void setAdviceChain(org.aopalliance.aop.Advice[] advices)
Public setter for theAdvice
.- Parameters:
advices
- the advice to set
afterPropertiesSet
public void afterPropertiesSet()
Set up interceptor with provided advice on thereceiveAndExecute(Object, Session, MessageConsumer)
method.- Specified by:
afterPropertiesSet
in interfaceorg.springframework.beans.factory.InitializingBean
- Overrides:
afterPropertiesSet
in classorg.springframework.jms.listener.AbstractJmsListeningContainer
- See Also:
AbstractJmsListeningContainer.afterPropertiesSet()
handleListenerException
protected void handleListenerException(java.lang.Throwable ex)
Override base class to prevent exceptions from being swallowed. Should be an injectable strategy (see SPR-4733).- Overrides:
handleListenerException
in classorg.springframework.jms.listener.AbstractMessageListenerContainer
- See Also:
AbstractMessageListenerContainer.handleListenerException(java.lang.Throwable)
receiveAndExecute
protected boolean receiveAndExecute(java.lang.Object invoker, javax.jms.Session session, javax.jms.MessageConsumer consumer) throws javax.jms.JMSException
Override base class method to wrap call in advice if provided.- Overrides:
receiveAndExecute
in classorg.springframework.jms.listener.AbstractPollingMessageListenerContainer
- Throws:
javax.jms.JMSException
- See Also:
AbstractPollingMessageListenerContainer.receiveAndExecute(Object, javax.jms.Session, javax.jms.MessageConsumer)
initializeProxy
public void initializeProxy()