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.JavaLangErrorHandler, AbstractMessageListenerContainer.SharedConnectionNotInitializedException, AbstractMessageListenerContainer.WrappedTransactionException
consumers
consumersMonitor, DEFAULT_DEBATCHING_ENABLED, DEFAULT_PREFETCH_COUNT, DEFAULT_RECOVERY_INTERVAL, DEFAULT_SHUTDOWN_TIMEOUT
logger
DEFAULT_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, setTaskScheduler
actualInvokeListener, addAfterReceivePostProcessors, afterPropertiesSet, causeChainHasImmediateAcknowledgeAmqpException, checkMessageListener, checkMismatchedQueues, configureAdminIfNeeded, debatch, destroy, doInvokeListener, doInvokeListener, doSetPossibleAuthenticationFailureFatal, executeListener, getAcknowledgeMode, getAdviceChain, getAfterReceivePostProcessors, getAmqpAdmin, getApplicationContext, getApplicationEventPublisher, getBatchingStrategy, getBeanName, getConnectionFactory, getConsumerArguments, getConsumerTagStrategy, getExclusiveConsumerExceptionLogger, getFailedDeclarationRetryInterval, getIdleEventInterval, getJavaLangErrorHandler, 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, isGlobalQos, isMismatchedQueuesFatal, isMissingQueuesFatal, isMissingQueuesFatalSet, isNoLocal, isPossibleAuthenticationFailureFatal, isPossibleAuthenticationFailureFatalSet, isRunning, isStatefulRetryFatalWithNullMessageId, lazyLoad, prepareHolderForRollback, publishConsumerFailedEvent, publishIdleContainerEvent, publishMissingQueueEvent, redeclareElementsIfNecessary, removeAfterReceivePostProcessor, setAcknowledgeMode, setAdviceChain, setAfterReceivePostProcessors, setAlwaysRequeueWithTxManagerRollback, setAmqpAdmin, setApplicationContext, setApplicationEventPublisher, setAutoDeclare, setAutoStartup, setBatchingStrategy, setBeanName, setConsumerArguments, setConsumerTagStrategy, setDeBatchingEnabled, setDefaultRequeueRejected, setErrorHandler, setErrorHandlerLoggerName, setExclusiveConsumerExceptionLogger, setExposeListenerChannel, setFailedDeclarationRetryInterval, setForceCloseChannel, setGlobalQos, setIdleEventInterval, setjavaLangErrorHandler, 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, wrapToListenerExecutionFailedExceptionIfNeeded
convertRabbitAccessException, createConnection, getChannel, getConnection, getTransactionalResourceHolder, isChannelTransacted, setChannelTransacted, setConnectionFactory
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
isConsumerBatchEnabled
public DirectReplyToMessageListenerContainer(ConnectionFactory connectionFactory)
public final void setConsumersPerQueue(int consumersPerQueue)
DirectMessageListenerContainer
setConsumersPerQueue
in class DirectMessageListenerContainer
consumersPerQueue
- the consumers per queue.public final void setMonitorInterval(long monitorInterval)
DirectMessageListenerContainer
setMonitorInterval
in class DirectMessageListenerContainer
monitorInterval
- 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)
AbstractMessageListenerContainer
setQueueNames
in class DirectMessageListenerContainer
queueName
- the desired queueName(s) (can not be null
)public final void addQueueNames(String... queueNames)
AbstractMessageListenerContainer
addQueueNames
in class DirectMessageListenerContainer
queueNames
- The queue(s) to add.public final boolean removeQueueNames(String... queueNames)
AbstractMessageListenerContainer
removeQueueNames
in class DirectMessageListenerContainer
queueNames
- The queue(s) to remove.queueNames
List.public void setMessageListener(MessageListener messageListener)
AbstractMessageListenerContainer
MessageListener
.setMessageListener
in class AbstractMessageListenerContainer
messageListener
- the listener.protected void doStart()
AbstractMessageListenerContainer
doStart
in class DirectMessageListenerContainer
protected void processMonitorTask()
DirectMessageListenerContainer
processMonitorTask
in class DirectMessageListenerContainer
protected int findIdleConsumer()
DirectMessageListenerContainer
findIdleConsumer
in class DirectMessageListenerContainer
protected void consumerRemoved(org.springframework.amqp.rabbit.listener.DirectMessageListenerContainer.SimpleConsumer consumer)
DirectMessageListenerContainer
consumerRemoved
in class DirectMessageListenerContainer
consumer
- 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.