org.springframework.amqp.rabbit.listener
Class SimpleMessageListenerContainer
java.lang.Object
org.springframework.amqp.rabbit.support.RabbitAccessor
org.springframework.amqp.rabbit.listener.AbstractRabbitListeningContainer
org.springframework.amqp.rabbit.listener.AbstractMessageListenerContainer
org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer
- All Implemented Interfaces:
- BeanNameAware, DisposableBean, InitializingBean, Lifecycle, Phased, SmartLifecycle
public class SimpleMessageListenerContainer
- extends AbstractMessageListenerContainer
- Author:
- Mark Pollack, Mark Fisher
| Methods inherited from class org.springframework.amqp.rabbit.listener.AbstractMessageListenerContainer |
checkMessageListener, commitIfNecessary, doExecuteListener, doInvokeListener, doInvokeListener, executeListener, getMessageListener, getQueueName, getRequiredQueueName, handleListenerException, invokeErrorHandler, invokeListener, isAutoAck, isChannelLocallyTransacted, isExposeListenerChannel, rollbackIfNecessary, rollbackOnExceptionIfNecessary, setAutoAck, setErrorHandler, setExposeListenerChannel, setMessageListener, setQueueName, setQueues |
| Methods inherited from class org.springframework.amqp.rabbit.listener.AbstractRabbitListeningContainer |
createSharedConnection, destroy, doStop, establishSharedConnection, getBeanName, getPhase, getSharedConnection, initialize, isActive, isAutoStartup, isRunning, prepareSharedConnection, refreshSharedConnection, runningAllowed, setAutoStartup, setBeanName, setPhase, shutdown, start, stop, stop, stopSharedConnection, validateConfiguration |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
SimpleMessageListenerContainer
public SimpleMessageListenerContainer()
SimpleMessageListenerContainer
public SimpleMessageListenerContainer(ConnectionFactory connectionFactory)
setConcurrentConsumers
public void setConcurrentConsumers(int concurrentConsumers)
- Specify the number of concurrent consumers to create. Default is 1.
Raising the number of concurrent consumers is recommendable in order
to scale the consumption of messages coming in from a queue. However,
note that any ordering guarantees are lost once multiple consumers are
registered. In general, stick with 1 consumer for low-volume queues.
afterPropertiesSet
public void afterPropertiesSet()
- Avoid the possibility of not configuring the CachingConnectionFactory in sync with the
number of concurrent consumers.
- Specified by:
afterPropertiesSet in interface InitializingBean- Overrides:
afterPropertiesSet in class AbstractRabbitListeningContainer
setTaskExecutor
public void setTaskExecutor(Executor taskExecutor)
getPrefetchCount
public int getPrefetchCount()
setPrefetchCount
public void setPrefetchCount(int prefetchCount)
getBlockingQueueConsumerCapacity
public int getBlockingQueueConsumerCapacity()
setBlockingQueueConsumerCapacity
public void setBlockingQueueConsumerCapacity(int blockingQueueConsumerCapacity)
sharedConnectionEnabled
protected final boolean sharedConnectionEnabled()
- Always use a shared Rabbit Connection.
- Specified by:
sharedConnectionEnabled in class AbstractRabbitListeningContainer
- See Also:
AbstractRabbitListeningContainer.getSharedConnection()
doInitialize
protected void doInitialize()
throws Exception
- Creates the specified number of concurrent consumers,
in the form of a Rabbit Channel plus associated MessageConsumer.
- Specified by:
doInitialize in class AbstractRabbitListeningContainer
- Throws:
Exception
AbstractRabbitListeningContainer.SharedConnectionNotInitializedException- See Also:
AbstractRabbitListeningContainer.getSharedConnection()
doStart
protected void doStart()
throws Exception
- Re-initializes this container's Rabbit message consumers,
if not initialized already. Then submits each consumer to
this container's task executor.
- Overrides:
doStart in class AbstractRabbitListeningContainer
- Throws:
Exception
AbstractRabbitListeningContainer.SharedConnectionNotInitializedException - if thrown by Rabbit API methods- See Also:
#startSharedConnection
doShutdown
protected void doShutdown()
- Description copied from class:
AbstractRabbitListeningContainer
- Close the registered invokers.
Subclasses need to implement this method for their specific
invoker management process.
A shared Rabbit Connection, if any, will automatically be closed
afterwards.
- Specified by:
doShutdown in class AbstractRabbitListeningContainer
- See Also:
AbstractRabbitListeningContainer.shutdown()
initializeConsumers
protected void initializeConsumers()
throws IOException
- Throws:
IOException
createBlockingQueueConsumer
protected BlockingQueueConsumer createBlockingQueueConsumer(com.rabbitmq.client.Channel channel)
throws IOException
- Throws:
IOException
processMessage
protected void processMessage(Message message,
com.rabbitmq.client.Channel channel)
Copyright © 2010. All Rights Reserved.