org.springframework.batch.container.jms
Class BatchMessageListenerContainer

java.lang.Object
  extended by org.springframework.jms.support.JmsAccessor
      extended by org.springframework.jms.support.destination.JmsDestinationAccessor
          extended by org.springframework.jms.listener.AbstractJmsListeningContainer
              extended by org.springframework.jms.listener.AbstractMessageListenerContainer
                  extended by org.springframework.jms.listener.AbstractPollingMessageListenerContainer
                      extended by org.springframework.jms.listener.DefaultMessageListenerContainer
                          extended by org.springframework.batch.container.jms.BatchMessageListenerContainer
All Implemented Interfaces:
BeanNameAware, DisposableBean, InitializingBean, Lifecycle

public class BatchMessageListenerContainer
extends 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 the TransactionInterceptor and the RepeatOperationsInterceptor 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 a RepeatOperations to receive multiple messages in the same thread. Use with a RepeatOperations and a transaction interceptor. If the transaction interceptor uses XA then use an XA connection factory, or else the TransactionAwareConnectionFactoryProxy 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
static interface BatchMessageListenerContainer.ContainerDelegate
           
 
Nested classes/interfaces inherited from class org.springframework.jms.listener.AbstractJmsListeningContainer
AbstractJmsListeningContainer.SharedConnectionNotInitializedException
 
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
 
Fields inherited from class org.springframework.jms.support.JmsAccessor
logger
 
Constructor Summary
BatchMessageListenerContainer()
           
 
Method Summary
 void afterPropertiesSet()
          Set up interceptor with provided advice on the receiveAndExecute(Object, Session, MessageConsumer) method.
protected  void handleListenerException(Throwable ex)
          Override base class to prevent exceptions from being swallowed.
 void initializeProxy()
           
protected  boolean receiveAndExecute(Object invoker, Session session, MessageConsumer consumer)
          Override base class method to wrap call in advice if provided.
 void setAdviceChain(org.aopalliance.aop.Advice[] advices)
          Public setter for the Advice.
 
Methods inherited from class org.springframework.jms.listener.DefaultMessageListenerContainer
createDefaultTaskExecutor, doInitialize, doRescheduleTask, doShutdown, establishSharedConnection, getActiveConsumerCount, getCacheLevel, getConcurrentConsumers, getIdleTaskExecutionLimit, getMaxConcurrentConsumers, getMaxMessagesPerTask, getScheduledConsumerCount, handleListenerSetupFailure, initialize, messageReceived, noMessageReceived, recoverAfterListenerSetupFailure, refreshConnectionUntilSuccessful, refreshDestination, scheduleNewInvokerIfAppropriate, setCacheLevel, setCacheLevelName, setConcurrentConsumers, setIdleTaskExecutionLimit, setMaxConcurrentConsumers, setMaxMessagesPerTask, setRecoveryInterval, setTaskExecutor, sharedConnectionEnabled, sleepInbetweenRecoveryAttempts, start, startSharedConnection, stop, stopSharedConnection, validateConfiguration
 
Methods inherited from class org.springframework.jms.listener.AbstractPollingMessageListenerContainer
createConsumer, createListenerConsumer, doReceiveAndExecute, getConnection, getSession, getTransactionManager, isPubSubNoLocal, isSessionLocallyTransacted, receiveMessage, setPubSubNoLocal, setReceiveTimeout, setSessionTransacted, setTransactionManager, setTransactionName, setTransactionTimeout
 
Methods inherited from class org.springframework.jms.listener.AbstractMessageListenerContainer
checkMessageListener, commitIfNecessary, doExecuteListener, doInvokeListener, doInvokeListener, executeListener, getDefaultSubscriptionName, getDestination, getDestinationDescription, getDestinationName, getDurableSubscriptionName, getExceptionListener, getMessageListener, getMessageSelector, invokeExceptionListener, invokeListener, isAcceptMessagesWhileStopping, isExposeListenerSession, isSubscriptionDurable, rollbackIfNecessary, rollbackOnExceptionIfNecessary, setAcceptMessagesWhileStopping, setDestination, setDestinationName, setDurableSubscriptionName, setExceptionListener, setExposeListenerSession, setMessageListener, setMessageSelector, setSubscriptionDurable
 
Methods inherited from class org.springframework.jms.listener.AbstractJmsListeningContainer
createSharedConnection, destroy, doStart, doStop, getBeanName, getClientId, getPausedTaskCount, getSharedConnection, isActive, isRunning, logRejectedTask, prepareSharedConnection, refreshSharedConnection, rescheduleTaskIfNecessary, resumePausedTasks, runningAllowed, setAutoStartup, setBeanName, setClientId, shutdown, stop
 
Methods inherited from class org.springframework.jms.support.destination.JmsDestinationAccessor
getDestinationResolver, isPubSubDomain, resolveDestinationName, setDestinationResolver, setPubSubDomain
 
Methods inherited from class org.springframework.jms.support.JmsAccessor
convertJmsAccessException, createConnection, createSession, getConnectionFactory, getSessionAcknowledgeMode, isClientAcknowledge, isSessionTransacted, setConnectionFactory, setSessionAcknowledgeMode, setSessionAcknowledgeModeName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.springframework.beans.factory.BeanNameAware
setBeanName
 

Constructor Detail

BatchMessageListenerContainer

public BatchMessageListenerContainer()
Method Detail

setAdviceChain

public void setAdviceChain(org.aopalliance.aop.Advice[] advices)
Public setter for the Advice.

Parameters:
advices - the advice to set

afterPropertiesSet

public void afterPropertiesSet()
Set up interceptor with provided advice on the receiveAndExecute(Object, Session, MessageConsumer) method.

Specified by:
afterPropertiesSet in interface InitializingBean
Overrides:
afterPropertiesSet in class AbstractJmsListeningContainer
See Also:
AbstractJmsListeningContainer.afterPropertiesSet()

handleListenerException

protected void handleListenerException(Throwable ex)
Override base class to prevent exceptions from being swallowed. Should be an injectable strategy (see SPR-4733).

Overrides:
handleListenerException in class AbstractMessageListenerContainer
See Also:
AbstractMessageListenerContainer.handleListenerException(java.lang.Throwable)

receiveAndExecute

protected boolean receiveAndExecute(Object invoker,
                                    Session session,
                                    MessageConsumer consumer)
                             throws JMSException
Override base class method to wrap call in advice if provided.

Overrides:
receiveAndExecute in class AbstractPollingMessageListenerContainer
Throws:
JMSException
See Also:
AbstractPollingMessageListenerContainer.receiveAndExecute(Object, javax.jms.Session, javax.jms.MessageConsumer)

initializeProxy

public void initializeProxy()


Copyright © 2010 SpringSource. All Rights Reserved.