public class DirectReplyToMessageListenerContainer extends DirectMessageListenerContainer
Address.AMQ_RABBITMQ_REPLY_TO. Consumers are added on-demand and
terminated when idle for idleEventInterval
(default 60 seconds).| Modifier and Type | Class and Description |
|---|---|
static class |
DirectReplyToMessageListenerContainer.ChannelHolder
Holder for a channel; contains a consumer epoch used to prevent inappropriate release
of the consumer after it has been allocated for reuse.
|
AbstractMessageListenerContainer.SharedConnectionNotInitializedException, AbstractMessageListenerContainer.WrappedTransactionExceptionconsumersconsumersMonitor, DEFAULT_DEBATCHING_ENABLED, DEFAULT_PREFETCH_COUNT, DEFAULT_RECOVERY_INTERVAL, DEFAULT_SHUTDOWN_TIMEOUTlogger| Constructor and Description |
|---|
DirectReplyToMessageListenerContainer(ConnectionFactory connectionFactory) |
| Modifier and Type | Method and Description |
|---|---|
void |
addQueueNames(String... queueNames)
Add queue(s) to this container's list of queues.
|
protected void |
consumerRemoved(org.springframework.amqp.rabbit.listener.DirectMessageListenerContainer.SimpleConsumer consumer)
Called whenever a consumer is removed.
|
protected void |
doStart()
Start this container, and notify all invoker tasks.
|
DirectReplyToMessageListenerContainer.ChannelHolder |
getChannelHolder()
Get the channel holder associated with a direct reply-to consumer; contains a
consumer epoch to prevent inappropriate releases.
|
protected void |
processMonitorTask()
Subclasses can override this to take additional actions when the monitor task runs.
|
void |
releaseConsumerFor(DirectReplyToMessageListenerContainer.ChannelHolder channelHolder,
boolean cancelConsumer,
String message)
Release the consumer associated with the channel for reuse.
|
boolean |
removeQueueNames(String... queueNames)
Remove queue(s) from this container's list of queues.
|
void |
setChannelAwareMessageListener(ChannelAwareMessageListener messageListener)
Set the
ChannelAwareMessageListener; strongly typed version of
AbstractMessageListenerContainer.setMessageListener(Object). |
void |
setConsumersPerQueue(int consumersPerQueue)
Each queue runs in its own consumer; set this property to create multiple
consumers for each queue.
|
void |
setMessageListener(MessageListener messageListener)
Set the
MessageListener; strongly typed version of
AbstractMessageListenerContainer.setMessageListener(Object). |
void |
setMessageListener(Object messageListener)
Set the message listener implementation to register.
|
void |
setMonitorInterval(long monitorInterval)
Set how often to run a task to check for failed consumers and idle containers.
|
void |
setQueueNames(String... queueName)
Set the name of the queue(s) to receive messages from.
|
actualStart, doInitialize, doRedeclareElementsIfNecessary, doShutdown, doStop, setAckTimeout, setExclusive, setMessagesPerAck, setMissingQueuesFatal, setTaskScheduleractualInvokeListener, addQueues, afterPropertiesSet, causeChainHasImmediateAcknowledgeAmqpException, checkMessageListener, checkMismatchedQueues, configureAdminIfNeeded, destroy, doInvokeListener, doInvokeListener, executeListener, getAcknowledgeMode, getAdviceChain, getApplicationContext, getApplicationEventPublisher, getBeanName, getConnectionFactory, getConsumerArguments, getConsumerTagStrategy, getExclusiveConsumerExceptionLogger, getFailedDeclarationRetryInterval, getIdleEventInterval, getLastReceive, getListenerId, getMessageConverter, getMessageListener, getMessagePropertiesConverter, getPhase, getPrefetchCount, getQueueNames, getQueueNamesAsSet, getRabbitAdmin, getRecoveryBackOff, getRoutingConnectionFactory, getRoutingLookupKey, getShutdownTimeout, getTaskExecutor, getTransactionAttribute, getTransactionManager, handleListenerException, initialize, initializeProxy, invokeErrorHandler, invokeListener, isActive, isAlwaysRequeueWithTxManagerRollback, isAutoDeclare, isAutoStartup, isChannelLocallyTransacted, isDefaultRequeueRejected, isExclusive, isExposeListenerChannel, isForceCloseChannel, isMismatchedQueuesFatal, isMissingQueuesFatal, isMissingQueuesFatalSet, isNoLocal, isPossibleAuthenticationFailureFatal, isPossibleAuthenticationFailureFatalSet, isRunning, isStatefulRetryFatalWithNullMessageId, prepareHolderForRollback, publishConsumerFailedEvent, publishIdleContainerEvent, redeclareElementsIfNecessary, removeQueues, setAcknowledgeMode, setAdviceChain, setAfterReceivePostProcessors, setAlwaysRequeueWithTxManagerRollback, setApplicationContext, setApplicationEventPublisher, setAutoDeclare, setAutoStartup, setBeanName, setConsumerArguments, setConsumerTagStrategy, setDeBatchingEnabled, setDefaultRequeueRejected, setErrorHandler, setExclusiveConsumerExceptionLogger, setExposeListenerChannel, setFailedDeclarationRetryInterval, setForceCloseChannel, setIdleEventInterval, setListenerId, setLookupKeyQualifier, setMessageConverter, setMessagePropertiesConverter, setMismatchedQueuesFatal, setNoLocal, setPhase, setPossibleAuthenticationFailureFatal, setPrefetchCount, setQueues, setRabbitAdmin, setRecoveryBackOff, setRecoveryInterval, setShutdownTimeout, setStatefulRetryFatalWithNullMessageId, setTaskExecutor, setTransactionAttribute, setTransactionManager, setupMessageListener, shutdown, start, stop, stop, updateLastReceive, validateConfiguration, wrapToListenerExecutionFailedExceptionIfNeededconvertRabbitAccessException, createConnection, getChannel, getConnection, getTransactionalResourceHolder, isChannelTransacted, setChannelTransacted, setConnectionFactorypublic DirectReplyToMessageListenerContainer(ConnectionFactory connectionFactory)
public final void setConsumersPerQueue(int consumersPerQueue)
DirectMessageListenerContainersetConsumersPerQueue in class DirectMessageListenerContainerconsumersPerQueue - the consumers per queue.public final void setMonitorInterval(long monitorInterval)
DirectMessageListenerContainersetMonitorInterval in class DirectMessageListenerContainermonitorInterval - the interval; default 10000 but it will be adjusted down
to the smallest of this, idleEventInterval / 2
(if configured) or
failedDeclarationRetryInterval.public final void setQueueNames(String... queueName)
AbstractMessageListenerContainersetQueueNames in class DirectMessageListenerContainerqueueName - the desired queueName(s) (can not be null)public final void addQueueNames(String... queueNames)
AbstractMessageListenerContaineraddQueueNames in class DirectMessageListenerContainerqueueNames - The queue(s) to add.public final boolean removeQueueNames(String... queueNames)
AbstractMessageListenerContainerremoveQueueNames in class DirectMessageListenerContainerqueueNames - The queue(s) to remove.queueNames List.public void setMessageListener(Object messageListener)
AbstractMessageListenerContainerMessageListener object or a Spring ChannelAwareMessageListener
object. Using the strongly typed
AbstractMessageListenerContainer.setChannelAwareMessageListener(ChannelAwareMessageListener) is preferred.setMessageListener in class AbstractMessageListenerContainermessageListener - The listener.MessageListener,
ChannelAwareMessageListenerpublic void setChannelAwareMessageListener(ChannelAwareMessageListener messageListener)
AbstractMessageListenerContainerChannelAwareMessageListener; strongly typed version of
AbstractMessageListenerContainer.setMessageListener(Object).setChannelAwareMessageListener in class AbstractMessageListenerContainermessageListener - the listener.public void setMessageListener(MessageListener messageListener)
AbstractMessageListenerContainerMessageListener; strongly typed version of
AbstractMessageListenerContainer.setMessageListener(Object).setMessageListener in class AbstractMessageListenerContainermessageListener - the listener.protected void doStart()
throws Exception
AbstractMessageListenerContainerdoStart in class DirectMessageListenerContainerException - if thrown by Rabbit API methodsprotected void processMonitorTask()
DirectMessageListenerContainerprocessMonitorTask in class DirectMessageListenerContainerprotected void consumerRemoved(org.springframework.amqp.rabbit.listener.DirectMessageListenerContainer.SimpleConsumer consumer)
DirectMessageListenerContainerconsumerRemoved in class DirectMessageListenerContainerconsumer - the consumer.public DirectReplyToMessageListenerContainer.ChannelHolder getChannelHolder()
public void releaseConsumerFor(DirectReplyToMessageListenerContainer.ChannelHolder channelHolder, boolean cancelConsumer, String message)
channelHolder - the channel holder.cancelConsumer - true to cancel the consumer.message - a message to be included in the cancel event if cancelConsumer is true.