Class ListenerContainerFactoryBean
- java.lang.Object
-
- org.springframework.beans.factory.config.AbstractFactoryBean<AbstractMessageListenerContainer>
-
- org.springframework.amqp.rabbit.config.ListenerContainerFactoryBean
-
- All Implemented Interfaces:
Aware
,BeanClassLoaderAware
,BeanFactoryAware
,BeanNameAware
,DisposableBean
,FactoryBean<AbstractMessageListenerContainer>
,InitializingBean
,ApplicationContextAware
,ApplicationEventPublisherAware
,Lifecycle
,Phased
,SmartLifecycle
public class ListenerContainerFactoryBean extends AbstractFactoryBean<AbstractMessageListenerContainer> implements ApplicationContextAware, BeanNameAware, ApplicationEventPublisherAware, SmartLifecycle
A Factory bean to create a listener container.- Since:
- 2.0
- Author:
- Gary Russell, Artem Bilan, Johno Crawford
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ListenerContainerFactoryBean.Type
The container type.
-
Field Summary
-
Fields inherited from class org.springframework.beans.factory.config.AbstractFactoryBean
logger
-
Fields inherited from interface org.springframework.beans.factory.FactoryBean
OBJECT_TYPE_ATTRIBUTE
-
Fields inherited from interface org.springframework.context.SmartLifecycle
DEFAULT_PHASE
-
-
Constructor Summary
Constructors Constructor Description ListenerContainerFactoryBean()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected AbstractMessageListenerContainer
createInstance()
Class<?>
getObjectType()
int
getPhase()
boolean
isAutoStartup()
boolean
isRunning()
void
setAcknowledgeMode(AcknowledgeMode acknowledgeMode)
void
setAdviceChain(Advice... adviceChain)
void
setAfterReceivePostProcessors(MessagePostProcessor... afterReceivePostProcessors)
void
setApplicationContext(ApplicationContext applicationContext)
void
setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher)
void
setAutoDeclare(boolean autoDeclare)
void
setAutoStartup(boolean autoStartup)
void
setBatchSize(int batchSize)
This property has several functions.void
setBeanName(String beanName)
void
setChannelTransacted(boolean transactional)
void
setConcurrentConsumers(int concurrentConsumers)
void
setConnectionFactory(ConnectionFactory connectionFactory)
void
setConsecutiveActiveTrigger(int consecutiveActiveTrigger)
void
setConsecutiveIdleTrigger(int consecutiveIdleTrigger)
void
setConsumerArguments(Map<String,Object> args)
void
setConsumerBatchEnabled(boolean consumerBatchEnabled)
Set to true to present a list of messages based on thesetBatchSize(int)
, if the container and listener support it.void
setConsumersPerQueue(int consumersPerQueue)
void
setConsumerTagStrategy(ConsumerTagStrategy consumerTagStrategy)
void
setDeBatchingEnabled(boolean deBatchingEnabled)
void
setDeclarationRetries(int declarationRetries)
void
setDefaultRequeueRejected(boolean defaultRequeueRejected)
void
setErrorHandler(ErrorHandler errorHandler)
void
setExclusive(boolean exclusive)
void
setExclusiveConsumerExceptionLogger(ConditionalExceptionLogger exclusiveConsumerExceptionLogger)
void
setExposeListenerChannel(boolean exposeListenerChannel)
void
setFailedDeclarationRetryInterval(long failedDeclarationRetryInterval)
void
setGlobalQos(boolean globalQos)
Apply prefetch to the entire channel.void
setIdleEventInterval(long idleEventInterval)
void
setListenerId(String listenerId)
void
setMaxConcurrentConsumers(int maxConcurrentConsumers)
void
setMessageListener(MessageListener messageListener)
void
setMessagePropertiesConverter(MessagePropertiesConverter messagePropertiesConverter)
void
setMismatchedQueuesFatal(boolean mismatchedQueuesFatal)
void
setMissingQueuesFatal(boolean missingQueuesFatal)
void
setMonitorInterval(long monitorInterval)
void
setNoLocal(Boolean noLocal)
void
setPhase(int phase)
void
setPossibleAuthenticationFailureFatal(Boolean possibleAuthenticationFailureFatal)
void
setPrefetchCount(int prefetchCount)
void
setQueueNames(String... queueName)
void
setQueues(Queue... queues)
void
setRabbitAdmin(RabbitAdmin rabbitAdmin)
void
setReceiveTimeout(long receiveTimeout)
void
setRecoveryBackOff(BackOff recoveryBackOff)
void
setRecoveryInterval(long recoveryInterval)
void
setRetryDeclarationInterval(long retryDeclarationInterval)
void
setShutdownTimeout(long shutdownTimeout)
void
setStartConsumerMinInterval(long startConsumerMinInterval)
void
setStopConsumerMinInterval(long stopConsumerMinInterval)
void
setTaskExecutor(Executor taskExecutor)
void
setTaskScheduler(TaskScheduler taskScheduler)
void
setTransactionAttribute(TransactionAttribute transactionAttribute)
void
setTransactionManager(PlatformTransactionManager transactionManager)
void
setType(ListenerContainerFactoryBean.Type type)
void
start()
void
stop()
void
stop(Runnable callback)
-
Methods inherited from class org.springframework.beans.factory.config.AbstractFactoryBean
afterPropertiesSet, destroy, destroyInstance, getBeanFactory, getBeanTypeConverter, getEarlySingletonInterfaces, getObject, isSingleton, setBeanClassLoader, setBeanFactory, setSingleton
-
-
-
-
Method Detail
-
setApplicationEventPublisher
public void setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher)
- Specified by:
setApplicationEventPublisher
in interfaceApplicationEventPublisherAware
-
setBeanName
public void setBeanName(String beanName)
- Specified by:
setBeanName
in interfaceBeanNameAware
-
setApplicationContext
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException
- Specified by:
setApplicationContext
in interfaceApplicationContextAware
- Throws:
BeansException
-
setType
public void setType(ListenerContainerFactoryBean.Type type)
-
setConnectionFactory
public void setConnectionFactory(ConnectionFactory connectionFactory)
-
setChannelTransacted
public void setChannelTransacted(boolean transactional)
-
setAcknowledgeMode
public void setAcknowledgeMode(AcknowledgeMode acknowledgeMode)
-
setQueueNames
public void setQueueNames(String... queueName)
-
setQueues
public void setQueues(Queue... queues)
-
setExposeListenerChannel
public void setExposeListenerChannel(boolean exposeListenerChannel)
-
setMessageListener
public void setMessageListener(MessageListener messageListener)
-
setErrorHandler
public void setErrorHandler(ErrorHandler errorHandler)
-
setDeBatchingEnabled
public void setDeBatchingEnabled(boolean deBatchingEnabled)
-
setAdviceChain
public void setAdviceChain(Advice... adviceChain)
-
setAfterReceivePostProcessors
public void setAfterReceivePostProcessors(MessagePostProcessor... afterReceivePostProcessors)
-
setAutoStartup
public void setAutoStartup(boolean autoStartup)
-
setPhase
public void setPhase(int phase)
-
setListenerId
public void setListenerId(String listenerId)
-
setConsumerTagStrategy
public void setConsumerTagStrategy(ConsumerTagStrategy consumerTagStrategy)
-
setNoLocal
public void setNoLocal(Boolean noLocal)
-
setExclusive
public void setExclusive(boolean exclusive)
-
setDefaultRequeueRejected
public void setDefaultRequeueRejected(boolean defaultRequeueRejected)
-
setPrefetchCount
public void setPrefetchCount(int prefetchCount)
-
setGlobalQos
public void setGlobalQos(boolean globalQos)
Apply prefetch to the entire channel.- Parameters:
globalQos
- true for a channel-wide prefetch.- Since:
- 2.2.17
- See Also:
Channel.basicQos(int, boolean)
-
setShutdownTimeout
public void setShutdownTimeout(long shutdownTimeout)
-
setIdleEventInterval
public void setIdleEventInterval(long idleEventInterval)
-
setTransactionManager
public void setTransactionManager(PlatformTransactionManager transactionManager)
-
setTransactionAttribute
public void setTransactionAttribute(TransactionAttribute transactionAttribute)
-
setTaskExecutor
public void setTaskExecutor(Executor taskExecutor)
-
setRecoveryInterval
public void setRecoveryInterval(long recoveryInterval)
-
setRecoveryBackOff
public void setRecoveryBackOff(BackOff recoveryBackOff)
-
setMessagePropertiesConverter
public void setMessagePropertiesConverter(MessagePropertiesConverter messagePropertiesConverter)
-
setRabbitAdmin
public void setRabbitAdmin(RabbitAdmin rabbitAdmin)
-
setMissingQueuesFatal
public void setMissingQueuesFatal(boolean missingQueuesFatal)
-
setPossibleAuthenticationFailureFatal
public void setPossibleAuthenticationFailureFatal(Boolean possibleAuthenticationFailureFatal)
-
setMismatchedQueuesFatal
public void setMismatchedQueuesFatal(boolean mismatchedQueuesFatal)
-
setAutoDeclare
public void setAutoDeclare(boolean autoDeclare)
-
setFailedDeclarationRetryInterval
public void setFailedDeclarationRetryInterval(long failedDeclarationRetryInterval)
-
setExclusiveConsumerExceptionLogger
public void setExclusiveConsumerExceptionLogger(ConditionalExceptionLogger exclusiveConsumerExceptionLogger)
-
setConsumersPerQueue
public void setConsumersPerQueue(int consumersPerQueue)
-
setTaskScheduler
public void setTaskScheduler(TaskScheduler taskScheduler)
-
setMonitorInterval
public void setMonitorInterval(long monitorInterval)
-
setConcurrentConsumers
public void setConcurrentConsumers(int concurrentConsumers)
-
setMaxConcurrentConsumers
public void setMaxConcurrentConsumers(int maxConcurrentConsumers)
-
setStartConsumerMinInterval
public void setStartConsumerMinInterval(long startConsumerMinInterval)
-
setStopConsumerMinInterval
public void setStopConsumerMinInterval(long stopConsumerMinInterval)
-
setConsecutiveActiveTrigger
public void setConsecutiveActiveTrigger(int consecutiveActiveTrigger)
-
setConsecutiveIdleTrigger
public void setConsecutiveIdleTrigger(int consecutiveIdleTrigger)
-
setReceiveTimeout
public void setReceiveTimeout(long receiveTimeout)
-
setBatchSize
public void setBatchSize(int batchSize)
This property has several functions.When the channel is transacted, it determines how many messages to process in a single transaction. It should be less than or equal to
the prefetch count
.It also affects how often acks are sent when using
AcknowledgeMode.AUTO
- one ack per BatchSize.Finally, when
setConsumerBatchEnabled(boolean)
is true, it determines how many records to include in the batch as long as sufficient messages arrive withinsetReceiveTimeout(long)
.IMPORTANT The batch size represents the number of physical messages received. If
setDeBatchingEnabled(boolean)
is true and a message is a batch created by a producer, the actual number of messages received by the listener will be larger than this batch size.Default is 1.
- Parameters:
batchSize
- the batch size- Since:
- 2.2
-
setConsumerBatchEnabled
public void setConsumerBatchEnabled(boolean consumerBatchEnabled)
Set to true to present a list of messages based on thesetBatchSize(int)
, if the container and listener support it.- Parameters:
consumerBatchEnabled
- true to create message batches in the container.- Since:
- 2.2
- See Also:
setBatchSize(int)
-
setDeclarationRetries
public void setDeclarationRetries(int declarationRetries)
-
setRetryDeclarationInterval
public void setRetryDeclarationInterval(long retryDeclarationInterval)
-
getObjectType
public Class<?> getObjectType()
- Specified by:
getObjectType
in interfaceFactoryBean<AbstractMessageListenerContainer>
- Specified by:
getObjectType
in classAbstractFactoryBean<AbstractMessageListenerContainer>
-
createInstance
protected AbstractMessageListenerContainer createInstance()
- Specified by:
createInstance
in classAbstractFactoryBean<AbstractMessageListenerContainer>
-
getPhase
public int getPhase()
- Specified by:
getPhase
in interfacePhased
- Specified by:
getPhase
in interfaceSmartLifecycle
-
isAutoStartup
public boolean isAutoStartup()
- Specified by:
isAutoStartup
in interfaceSmartLifecycle
-
stop
public void stop(Runnable callback)
- Specified by:
stop
in interfaceSmartLifecycle
-
-