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_TIMEOUTloggerDEFAULT_PHASE| 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.
|
protected int |
findIdleConsumer()
When adjusting down, return a consumer that can be canceled.
|
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 |
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. |
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, addQueues, doInitialize, doRedeclareElementsIfNecessary, doShutdown, doStop, removeQueues, setAckTimeout, setExclusive, setMessagesPerAck, setMissingQueuesFatal, setTaskScheduleractualInvokeListener, addAfterReceivePostProcessors, afterPropertiesSet, causeChainHasImmediateAcknowledgeAmqpException, checkMessageListener, checkMismatchedQueues, configureAdminIfNeeded, debatch, destroy, doInvokeListener, doInvokeListener, executeListener, getAcknowledgeMode, getAdviceChain, getAfterReceivePostProcessors, getAmqpAdmin, getApplicationContext, getApplicationEventPublisher, getBatchingStrategy, getBeanName, getConnectionFactory, getConsumeDelay, getConsumerArguments, getConsumerTagStrategy, getExclusiveConsumerExceptionLogger, getFailedDeclarationRetryInterval, getIdleEventInterval, getLastReceive, getListenerId, getMessageListener, getMessagePropertiesConverter, getPhase, getPrefetchCount, getQueueNames, getQueueNamesAsSet, getQueueNamesToQueues, getRecoveryBackOff, getRoutingConnectionFactory, getRoutingLookupKey, getShutdownTimeout, getTaskExecutor, getTransactionAttribute, getTransactionManager, handleListenerException, initialize, initializeProxy, invokeErrorHandler, invokeListener, isActive, isAlwaysRequeueWithTxManagerRollback, isAutoDeclare, isAutoStartup, isChannelLocallyTransacted, isDeBatchingEnabled, isDefaultRequeueRejected, isExclusive, isExposeListenerChannel, isForceCloseChannel, isMismatchedQueuesFatal, isMissingQueuesFatal, isMissingQueuesFatalSet, isNoLocal, isPossibleAuthenticationFailureFatal, isPossibleAuthenticationFailureFatalSet, isRunning, isStatefulRetryFatalWithNullMessageId, lazyLoad, prepareHolderForRollback, publishConsumerFailedEvent, publishIdleContainerEvent, redeclareElementsIfNecessary, removeAfterReceivePostProcessor, setAcknowledgeMode, setAdviceChain, setAfterReceivePostProcessors, setAlwaysRequeueWithTxManagerRollback, setAmqpAdmin, setApplicationContext, setApplicationEventPublisher, setAutoDeclare, setAutoStartup, setBatchingStrategy, setBeanName, setConsumeDelay, setConsumerArguments, setConsumerTagStrategy, setDeBatchingEnabled, setDefaultRequeueRejected, setErrorHandler, setErrorHandlerLoggerName, setExclusiveConsumerExceptionLogger, setExposeListenerChannel, setFailedDeclarationRetryInterval, setForceCloseChannel, setIdleEventInterval, setListenerId, setLookupKeyQualifier, setMessagePropertiesConverter, setMicrometerEnabled, setMicrometerTags, setMismatchedQueuesFatal, setNoLocal, setPhase, setPossibleAuthenticationFailureFatal, setPrefetchCount, setQueues, setRecoveryBackOff, setRecoveryInterval, setShutdownTimeout, setStatefulRetryFatalWithNullMessageId, setTaskExecutor, setTransactionAttribute, setTransactionManager, setupMessageListener, shutdown, start, stop, stop, updateLastReceive, validateConfiguration, wrapToListenerExecutionFailedExceptionIfNeededconvertRabbitAccessException, createConnection, getChannel, getConnection, getTransactionalResourceHolder, isChannelTransacted, setChannelTransacted, setConnectionFactoryclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitisConsumerBatchEnabledpublic 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(MessageListener messageListener)
AbstractMessageListenerContainerMessageListener.setMessageListener in class AbstractMessageListenerContainermessageListener - the listener.protected void doStart()
AbstractMessageListenerContainerdoStart in class DirectMessageListenerContainerprotected void processMonitorTask()
DirectMessageListenerContainerprocessMonitorTask in class DirectMessageListenerContainerprotected int findIdleConsumer()
DirectMessageListenerContainerfindIdleConsumer 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, @Nullable 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.