Class AbstractRabbitListenerEndpoint
java.lang.Object
org.springframework.amqp.rabbit.listener.AbstractRabbitListenerEndpoint
- All Implemented Interfaces:
RabbitListenerEndpoint,Aware,BeanFactoryAware
- Direct Known Subclasses:
MethodRabbitListenerEndpoint,SimpleRabbitListenerEndpoint
public abstract class AbstractRabbitListenerEndpoint
extends Object
implements RabbitListenerEndpoint, BeanFactoryAware
Base model for a Rabbit listener endpoint.
- Since:
- 1.4
- Author:
- Stephane Nicoll, Gary Russell, Artem Bilan
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract MessageListenercreateMessageListener(MessageListenerContainer container) Create aMessageListenerthat is able to serve this endpoint for the specified container.Override the container factory'sAcknowledgeMode.getAdmin()Override of the default autoStartup property.protected BeanExpressionContextprotected BeanFactoryprotected BeanResolverThe concurrency of this endpoint; Not used by this abstract class; used by subclasses to set the concurrency appropriate for the container type.protected StringBuildergetGroup()getId()Used by the container factory to check if this endpoint supports the preferred way for a container factory to pass a message converter to the endpoint's adapter.Get the reply content type.Return aReplyPostProcessorto post process a reply message before it is sent.protected BeanExpressionResolverGet the task executor to use for this endpoint's listener container.booleanbooleanReturn whether the content type set by a converter prevails or not.booleanvoidsetAckMode(AcknowledgeMode mode) voidSet theAmqpAdmininstance to use.voidsetAutoStartup(Boolean autoStartup) Override the default autoStartup property.voidsetBatchingStrategy(BatchingStrategy batchingStrategy) Set aBatchingStrategyto use when debatching messages.voidsetBatchListener(boolean batchListener) Set to true if this endpoint should create a batch listener.voidsetBeanFactory(BeanFactory beanFactory) voidsetConcurrency(String concurrency) Set the concurrency of this endpoint; usually overrides any concurrency settings on the container factory.voidsetConverterWinsContentType(boolean converterWinsContentType) Set whether the content type set by a converter prevails or not.voidsetExclusive(boolean exclusive) Set if a single consumer in the container will have exclusive use of the queues, preventing other consumers from receiving messages from the queue(s).voidSet the group for the corresponding listener container.voidvoidsetMessageConverter(MessageConverter messageConverter) The preferred way for a container factory to pass a message converter to the endpoint's adapter.voidsetPriority(Integer priority) Set the priority of this endpoint.voidsetQueueNames(String... queueNames) Set the queue names to use.voidSet the queues to use.voidsetReplyContentType(String replyContentType) Set the reply content type.voidsetReplyPostProcessor(ReplyPostProcessor replyPostProcessor) Set aReplyPostProcessorto post process a response message before it is sent.voidsetTaskExecutor(TaskExecutor taskExecutor) Override the default task executor.voidsetupListenerContainer(MessageListenerContainer listenerContainer) Setup the specified message listener container with the model defined by this endpoint.toString()
-
Constructor Details
-
AbstractRabbitListenerEndpoint
public AbstractRabbitListenerEndpoint()
-
-
Method Details
-
setBeanFactory
- Specified by:
setBeanFactoryin interfaceBeanFactoryAware- Throws:
BeansException
-
getBeanFactory
-
getResolver
-
getBeanResolver
-
getBeanExpressionContext
-
setId
-
getId
- Specified by:
getIdin interfaceRabbitListenerEndpoint- Returns:
- the id of this endpoint. The id can be further qualified when the endpoint is resolved against its actual listener container.
- See Also:
-
setQueues
Set the queues to use. Either theQueueinstances or the queue names should be provided, but not both.- Parameters:
queues- to set.- See Also:
-
getQueues
- Returns:
- the queues for this endpoint.
-
getQueueNames
- Returns:
- the queue names for this endpoint.
-
setQueueNames
Set the queue names to use. Either theQueueinstances or the queue names should be provided, but not both.- Parameters:
queueNames- to set.- See Also:
-
setExclusive
public void setExclusive(boolean exclusive) Set if a single consumer in the container will have exclusive use of the queues, preventing other consumers from receiving messages from the queue(s).- Parameters:
exclusive- the exclusivebooleanflag.
-
isExclusive
public boolean isExclusive()- Returns:
- the exclusive
booleanflag.
-
setPriority
Set the priority of this endpoint.- Parameters:
priority- the priority value.
-
getPriority
- Returns:
- the priority of this endpoint or
nullif no priority is set.
-
setConcurrency
Set the concurrency of this endpoint; usually overrides any concurrency settings on the container factory. Contents depend on container implementation.- Parameters:
concurrency- the concurrency.- Since:
- 2.0
-
getConcurrency
The concurrency of this endpoint; Not used by this abstract class; used by subclasses to set the concurrency appropriate for the container type.- Specified by:
getConcurrencyin interfaceRabbitListenerEndpoint- Returns:
- the concurrency.
- Since:
- 2.0
-
setAdmin
Set theAmqpAdmininstance to use.- Parameters:
admin- theAmqpAdmininstance.
-
getAdmin
- Returns:
- the
AmqpAdmininstance to use ornullif none is configured.
-
getGroup
- Specified by:
getGroupin interfaceRabbitListenerEndpoint- Returns:
- the group of this endpoint or null if not in a group.
-
setGroup
Set the group for the corresponding listener container.- Parameters:
group- the group.- Since:
- 1.5
-
setAutoStartup
Override the default autoStartup property.- Parameters:
autoStartup- the autoStartup.- Since:
- 2.0
-
getAutoStartup
Description copied from interface:RabbitListenerEndpointOverride of the default autoStartup property.- Specified by:
getAutoStartupin interfaceRabbitListenerEndpoint- Returns:
- the autoStartup.
-
getMessageConverter
Description copied from interface:RabbitListenerEndpointUsed by the container factory to check if this endpoint supports the preferred way for a container factory to pass a message converter to the endpoint's adapter. If null is returned, the factory will fall back to the legacy method of passing the converter via the container.- Specified by:
getMessageConverterin interfaceRabbitListenerEndpoint- Returns:
- the converter.
-
setMessageConverter
Description copied from interface:RabbitListenerEndpointThe preferred way for a container factory to pass a message converter to the endpoint's adapter.- Specified by:
setMessageConverterin interfaceRabbitListenerEndpoint- Parameters:
messageConverter- the converter.
-
getTaskExecutor
Description copied from interface:RabbitListenerEndpointGet the task executor to use for this endpoint's listener container. Overrides any executor set on the container factory.- Specified by:
getTaskExecutorin interfaceRabbitListenerEndpoint- Returns:
- the executor.
-
setTaskExecutor
Override the default task executor.- Parameters:
taskExecutor- the executor.- Since:
- 2.2
-
isBatchListener
public boolean isBatchListener() -
setBatchListener
public void setBatchListener(boolean batchListener) Set to true if this endpoint should create a batch listener.- Specified by:
setBatchListenerin interfaceRabbitListenerEndpoint- Parameters:
batchListener- true for a batch listener.- Since:
- 2.2
- See Also:
-
getBatchingStrategy
-
setBatchingStrategy
Description copied from interface:RabbitListenerEndpointSet aBatchingStrategyto use when debatching messages.- Specified by:
setBatchingStrategyin interfaceRabbitListenerEndpoint- Parameters:
batchingStrategy- the batching strategy.- See Also:
-
getAckMode
Description copied from interface:RabbitListenerEndpointOverride the container factory'sAcknowledgeMode.- Specified by:
getAckModein interfaceRabbitListenerEndpoint- Returns:
- the acknowledgment mode.
-
setAckMode
-
getReplyPostProcessor
Description copied from interface:RabbitListenerEndpointReturn aReplyPostProcessorto post process a reply message before it is sent.- Specified by:
getReplyPostProcessorin interfaceRabbitListenerEndpoint- Returns:
- the post processor.
-
setReplyPostProcessor
Set aReplyPostProcessorto post process a response message before it is sent.- Parameters:
replyPostProcessor- the post processor.- Since:
- 2.2.5
-
getReplyContentType
Description copied from interface:RabbitListenerEndpointGet the reply content type.- Specified by:
getReplyContentTypein interfaceRabbitListenerEndpoint- Returns:
- the content type.
-
setReplyContentType
Set the reply content type.- Parameters:
replyContentType- the content type.- Since:
- 2.3
-
isConverterWinsContentType
public boolean isConverterWinsContentType()Description copied from interface:RabbitListenerEndpointReturn whether the content type set by a converter prevails or not.- Specified by:
isConverterWinsContentTypein interfaceRabbitListenerEndpoint- Returns:
- false to always apply the reply content type.
-
setConverterWinsContentType
public void setConverterWinsContentType(boolean converterWinsContentType) Set whether the content type set by a converter prevails or not.- Parameters:
converterWinsContentType- false to always apply the reply content type.- Since:
- 2.3
-
setupListenerContainer
Description copied from interface:RabbitListenerEndpointSetup the specified message listener container with the model defined by this endpoint.This endpoint must provide the requested missing option(s) of the specified container to make it usable. Usually, this is about setting the
queuesand themessageListenerto use but an implementation may override any default setting that was already set.- Specified by:
setupListenerContainerin interfaceRabbitListenerEndpoint- Parameters:
listenerContainer- the listener container to configure
-
createMessageListener
Create aMessageListenerthat is able to serve this endpoint for the specified container.- Parameters:
container- theMessageListenerContainerto create aMessageListener.- Returns:
- a a
MessageListenerinstance.
-
getEndpointDescription
- Returns:
- a description for this endpoint.
Available to subclasses, for inclusion in their
toString()result.
-
toString
-