Class AbstractRabbitListenerContainerFactory<C extends AbstractMessageListenerContainer>
- java.lang.Object
-
- org.springframework.amqp.rabbit.config.BaseRabbitListenerContainerFactory<C>
-
- org.springframework.amqp.rabbit.config.AbstractRabbitListenerContainerFactory<C>
-
- Type Parameters:
C- the container type.
- All Implemented Interfaces:
RabbitListenerContainerFactory<C>,Aware,ApplicationContextAware,ApplicationEventPublisherAware
- Direct Known Subclasses:
DirectRabbitListenerContainerFactory,SimpleRabbitListenerContainerFactory
public abstract class AbstractRabbitListenerContainerFactory<C extends AbstractMessageListenerContainer> extends BaseRabbitListenerContainerFactory<C> implements ApplicationContextAware, ApplicationEventPublisherAware
RabbitListenerContainerFactoryfor Spring's base container implementation.- Since:
- 1.4
- Author:
- Stephane Nicoll, Gary Russell, Artem Bilan, Joris Kuipers
- See Also:
AbstractMessageListenerContainer
-
-
Field Summary
Fields Modifier and Type Field Description protected AtomicIntegercounterprotected Loglogger
-
Constructor Summary
Constructors Constructor Description AbstractRabbitListenerContainerFactory()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract CcreateContainerInstance()Create an empty container instance.CcreateListenerContainer(RabbitListenerEndpoint endpoint)Create aMessageListenerContainerfor the givenRabbitListenerEndpoint.Advice[]getAdviceChain()protected voidinitializeContainer(C instance, RabbitListenerEndpoint endpoint)Further initialize the specified container.voidsetAcknowledgeMode(AcknowledgeMode acknowledgeMode)voidsetAdviceChain(Advice... adviceChain)voidsetAfterReceivePostProcessors(MessagePostProcessor... postProcessors)Set post processors which will be applied after the Message is received.voidsetApplicationContext(ApplicationContext applicationContext)voidsetApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher)voidsetAutoStartup(Boolean autoStartup)voidsetBatchingStrategy(BatchingStrategy batchingStrategy)Set aBatchingStrategyto use when debatching messages.voidsetBatchListener(boolean isBatch)Set to true to receive a list of debatched messages that were created by aBatchingRabbitTemplate.voidsetChannelTransacted(Boolean channelTransacted)voidsetConnectionFactory(ConnectionFactory connectionFactory)voidsetConsumerTagStrategy(ConsumerTagStrategy consumerTagStrategy)voidsetContainerCustomizer(ContainerCustomizer<C> containerCustomizer)Set aContainerCustomizerthat is invoked after a container is created and configured to enable further customization of the container.voidsetDeBatchingEnabled(Boolean deBatchingEnabled)Determine whether or not the container should de-batch batched messages (true) or call the listener with the batch (false).voidsetErrorHandler(ErrorHandler errorHandler)voidsetFailedDeclarationRetryInterval(Long failedDeclarationRetryInterval)voidsetGlobalQos(boolean globalQos)Apply prefetch to the entire channel.voidsetIdleEventInterval(Long idleEventInterval)How often to publish idle container events.voidsetMessageConverter(MessageConverter messageConverter)voidsetMismatchedQueuesFatal(Boolean mismatchedQueuesFatal)voidsetMissingQueuesFatal(Boolean missingQueuesFatal)voidsetPhase(int phase)voidsetPrefetchCount(Integer prefetch)voidsetRecoveryBackOff(BackOff recoveryBackOff)voidsetRecoveryInterval(Long recoveryInterval)voidsetTaskExecutor(Executor taskExecutor)voidsetTransactionManager(PlatformTransactionManager transactionManager)-
Methods inherited from class org.springframework.amqp.rabbit.config.BaseRabbitListenerContainerFactory
applyCommonOverrides, getDefaultRequeueRejected, setBeforeSendReplyPostProcessors, setDefaultRequeueRejected, setReplyRecoveryCallback, setRetryTemplate
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.springframework.amqp.rabbit.listener.RabbitListenerContainerFactory
createListenerContainer
-
-
-
-
Field Detail
-
logger
protected final Log logger
-
counter
protected final AtomicInteger counter
-
-
Method Detail
-
setConnectionFactory
public void setConnectionFactory(ConnectionFactory connectionFactory)
- Parameters:
connectionFactory- The connection factory.- See Also:
RabbitAccessor.setConnectionFactory(ConnectionFactory)
-
setErrorHandler
public void setErrorHandler(ErrorHandler errorHandler)
- Parameters:
errorHandler- The error handler.- See Also:
AbstractMessageListenerContainer.setErrorHandler(org.springframework.util.ErrorHandler)
-
setMessageConverter
public void setMessageConverter(MessageConverter messageConverter)
- Parameters:
messageConverter- the message converter to use- See Also:
RabbitListenerEndpoint.setMessageConverter(MessageConverter)
-
setAcknowledgeMode
public void setAcknowledgeMode(AcknowledgeMode acknowledgeMode)
- Parameters:
acknowledgeMode- the acknowledge mode to set. Defaults toAcknowledgeMode.AUTO- See Also:
AbstractMessageListenerContainer.setAcknowledgeMode(AcknowledgeMode)
-
setChannelTransacted
public void setChannelTransacted(Boolean channelTransacted)
- Parameters:
channelTransacted- the flag value to set- See Also:
RabbitAccessor.setChannelTransacted(boolean)
-
setTaskExecutor
public void setTaskExecutor(Executor taskExecutor)
- Parameters:
taskExecutor- theExecutorto use.- See Also:
AbstractMessageListenerContainer.setTaskExecutor(java.util.concurrent.Executor)
-
setTransactionManager
public void setTransactionManager(PlatformTransactionManager transactionManager)
- Parameters:
transactionManager- thePlatformTransactionManagerto use.- See Also:
AbstractMessageListenerContainer.setTransactionManager(org.springframework.transaction.PlatformTransactionManager)
-
setPrefetchCount
public void setPrefetchCount(Integer prefetch)
- Parameters:
prefetch- the prefetch count- See Also:
AbstractMessageListenerContainer.setPrefetchCount(int)
-
getAdviceChain
@Nullable public Advice[] getAdviceChain()
- Returns:
- the advice chain that was set. Defaults to
null. - Since:
- 1.7.4
-
setAdviceChain
public void setAdviceChain(Advice... adviceChain)
- Parameters:
adviceChain- the advice chain to set.- See Also:
AbstractMessageListenerContainer.setAdviceChain(org.aopalliance.aop.Advice...)
-
setRecoveryInterval
public void setRecoveryInterval(Long recoveryInterval)
- Parameters:
recoveryInterval- The recovery interval.- See Also:
AbstractMessageListenerContainer.setRecoveryInterval(long)
-
setRecoveryBackOff
public void setRecoveryBackOff(BackOff recoveryBackOff)
- Parameters:
recoveryBackOff- The BackOff to recover.- Since:
- 1.5
- See Also:
AbstractMessageListenerContainer.setRecoveryBackOff(BackOff)
-
setMissingQueuesFatal
public void setMissingQueuesFatal(Boolean missingQueuesFatal)
- Parameters:
missingQueuesFatal- the missingQueuesFatal to set.- See Also:
AbstractMessageListenerContainer.setMissingQueuesFatal(boolean)
-
setMismatchedQueuesFatal
public void setMismatchedQueuesFatal(Boolean mismatchedQueuesFatal)
- Parameters:
mismatchedQueuesFatal- the mismatchedQueuesFatal to set.- Since:
- 1.6
- See Also:
AbstractMessageListenerContainer.setMismatchedQueuesFatal(boolean)
-
setConsumerTagStrategy
public void setConsumerTagStrategy(ConsumerTagStrategy consumerTagStrategy)
- Parameters:
consumerTagStrategy- the consumerTagStrategy to set- See Also:
AbstractMessageListenerContainer.setConsumerTagStrategy(ConsumerTagStrategy)
-
setIdleEventInterval
public void setIdleEventInterval(Long idleEventInterval)
How often to publish idle container events.- Parameters:
idleEventInterval- the interval.
-
setFailedDeclarationRetryInterval
public void setFailedDeclarationRetryInterval(Long failedDeclarationRetryInterval)
-
setApplicationEventPublisher
public void setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher)
- Specified by:
setApplicationEventPublisherin interfaceApplicationEventPublisherAware
-
setApplicationContext
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException
- Specified by:
setApplicationContextin interfaceApplicationContextAware- Throws:
BeansException
-
setAutoStartup
public void setAutoStartup(Boolean autoStartup)
- Parameters:
autoStartup- true for auto startup.- See Also:
AbstractMessageListenerContainer.setAutoStartup(boolean)
-
setPhase
public void setPhase(int phase)
- Parameters:
phase- The phase.- See Also:
AbstractMessageListenerContainer.setPhase(int)
-
setAfterReceivePostProcessors
public void setAfterReceivePostProcessors(MessagePostProcessor... postProcessors)
Set post processors which will be applied after the Message is received.- Parameters:
postProcessors- the post processors.- Since:
- 2.0
- See Also:
AbstractMessageListenerContainer.setAfterReceivePostProcessors(MessagePostProcessor...)
-
setContainerCustomizer
public void setContainerCustomizer(ContainerCustomizer<C> containerCustomizer)
Set aContainerCustomizerthat is invoked after a container is created and configured to enable further customization of the container.- Parameters:
containerCustomizer- the customizer.- Since:
- 2.2.2
-
setBatchListener
public void setBatchListener(boolean isBatch)
Set to true to receive a list of debatched messages that were created by aBatchingRabbitTemplate.- Parameters:
isBatch- true for a batch listener.- Since:
- 2.2
- See Also:
setBatchingStrategy(BatchingStrategy)
-
setBatchingStrategy
public void setBatchingStrategy(BatchingStrategy batchingStrategy)
Set aBatchingStrategyto use when debatching messages.- Parameters:
batchingStrategy- the batching strategy.- Since:
- 2.2
- See Also:
setBatchListener(boolean)
-
setDeBatchingEnabled
public void setDeBatchingEnabled(Boolean deBatchingEnabled)
Determine whether or not the container should de-batch batched messages (true) or call the listener with the batch (false). Default: true.- Parameters:
deBatchingEnabled- whether or not to disable de-batching of messages.- Since:
- 2.2
- See Also:
AbstractMessageListenerContainer.setDeBatchingEnabled(boolean)
-
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)
-
createListenerContainer
public C createListenerContainer(RabbitListenerEndpoint endpoint)
Description copied from interface:RabbitListenerContainerFactoryCreate aMessageListenerContainerfor the givenRabbitListenerEndpoint.- Specified by:
createListenerContainerin interfaceRabbitListenerContainerFactory<C extends AbstractMessageListenerContainer>- Specified by:
createListenerContainerin classBaseRabbitListenerContainerFactory<C extends AbstractMessageListenerContainer>- Parameters:
endpoint- the endpoint to configure.- Returns:
- the created container.
-
createContainerInstance
protected abstract C createContainerInstance()
Create an empty container instance.- Returns:
- the new container instance.
-
initializeContainer
protected void initializeContainer(C instance, RabbitListenerEndpoint endpoint)
Further initialize the specified container.Subclasses can inherit from this method to apply extra configuration if necessary.
- Parameters:
instance- the container instance to configure.endpoint- the endpoint.
-
-