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
-
Method Summary
Modifier and TypeMethodDescriptionprotected abstract MessageListener
createMessageListener
(MessageListenerContainer container) Create aMessageListener
that is able to serve this endpoint for the specified container.Override the container factory'sAcknowledgeMode
.getAdmin()
Override of the default autoStartup property.Return this endpoint's batching strategy, or null.Whether this endpoint is for a batch listener.protected BeanExpressionContext
protected BeanFactory
protected BeanResolver
The concurrency of this endpoint; Not used by this abstract class; used by subclasses to set the concurrency appropriate for the container type.protected StringBuilder
getGroup()
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 aReplyPostProcessor
to post process a reply message before it is sent.protected BeanExpressionResolver
Get the task executor to use for this endpoint's listener container.boolean
True if this endpoint is for a batch listener.boolean
Return whether the content type set by a converter prevails or not.boolean
void
setAckMode
(AcknowledgeMode mode) void
Set theAmqpAdmin
instance to use.void
setAutoStartup
(Boolean autoStartup) Override the default autoStartup property.void
setBatchingStrategy
(BatchingStrategy batchingStrategy) Set aBatchingStrategy
to use when debatching messages.void
setBatchListener
(boolean batchListener) Set to true if this endpoint should create a batch listener.void
setBeanFactory
(BeanFactory beanFactory) void
setConcurrency
(String concurrency) Set the concurrency of this endpoint; usually overrides any concurrency settings on the container factory.void
setConverterWinsContentType
(boolean converterWinsContentType) Set whether the content type set by a converter prevails or not.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).void
Set the group for the corresponding listener container.void
void
setMessageConverter
(MessageConverter messageConverter) The preferred way for a container factory to pass a message converter to the endpoint's adapter.void
setPriority
(Integer priority) Set the priority of this endpoint.void
setQueueNames
(String... queueNames) Set the queue names to use.void
Set the queues to use.void
setReplyContentType
(String replyContentType) Set the reply content type.void
setReplyPostProcessor
(ReplyPostProcessor replyPostProcessor) Set aReplyPostProcessor
to post process a response message before it is sent.void
setTaskExecutor
(TaskExecutor taskExecutor) Override the default task executor.void
setupListenerContainer
(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:
setBeanFactory
in interfaceBeanFactoryAware
- Throws:
BeansException
-
getBeanFactory
-
getResolver
-
getBeanResolver
-
getBeanExpressionContext
-
setId
-
getId
- Specified by:
getId
in 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 theQueue
instances 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 theQueue
instances 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 exclusiveboolean
flag.
-
isExclusive
public boolean isExclusive()- Returns:
- the exclusive
boolean
flag.
-
setPriority
Set the priority of this endpoint.- Parameters:
priority
- the priority value.
-
getPriority
- Returns:
- the priority of this endpoint or
null
if 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:
getConcurrency
in interfaceRabbitListenerEndpoint
- Returns:
- the concurrency.
- Since:
- 2.0
-
setAdmin
Set theAmqpAdmin
instance to use.- Parameters:
admin
- theAmqpAdmin
instance.
-
getAdmin
- Returns:
- the
AmqpAdmin
instance to use ornull
if none is configured.
-
getGroup
- Specified by:
getGroup
in 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:RabbitListenerEndpoint
Override of the default autoStartup property.- Specified by:
getAutoStartup
in interfaceRabbitListenerEndpoint
- Returns:
- the autoStartup.
-
getMessageConverter
Description copied from interface:RabbitListenerEndpoint
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. If null is returned, the factory will fall back to the legacy method of passing the converter via the container.- Specified by:
getMessageConverter
in interfaceRabbitListenerEndpoint
- Returns:
- the converter.
-
setMessageConverter
Description copied from interface:RabbitListenerEndpoint
The preferred way for a container factory to pass a message converter to the endpoint's adapter.- Specified by:
setMessageConverter
in interfaceRabbitListenerEndpoint
- Parameters:
messageConverter
- the converter.
-
getTaskExecutor
Description copied from interface:RabbitListenerEndpoint
Get the task executor to use for this endpoint's listener container. Overrides any executor set on the container factory.- Specified by:
getTaskExecutor
in interfaceRabbitListenerEndpoint
- Returns:
- the executor.
-
setTaskExecutor
Override the default task executor.- Parameters:
taskExecutor
- the executor.- Since:
- 2.2
-
isBatchListener
public boolean isBatchListener()True if this endpoint is for a batch listener.- Returns:
- true if batch.
-
getBatchListener
Description copied from interface:RabbitListenerEndpoint
Whether this endpoint is for a batch listener.- Specified by:
getBatchListener
in interfaceRabbitListenerEndpoint
- Returns:
Boolean.TRUE
if batch.
-
setBatchListener
public void setBatchListener(boolean batchListener) Set to true if this endpoint should create a batch listener.- Specified by:
setBatchListener
in interfaceRabbitListenerEndpoint
- Parameters:
batchListener
- true for a batch listener.- Since:
- 2.2
- See Also:
-
getBatchingStrategy
Description copied from interface:RabbitListenerEndpoint
Return this endpoint's batching strategy, or null.- Specified by:
getBatchingStrategy
in interfaceRabbitListenerEndpoint
- Returns:
- the strategy.
-
setBatchingStrategy
Description copied from interface:RabbitListenerEndpoint
Set aBatchingStrategy
to use when debatching messages.- Specified by:
setBatchingStrategy
in interfaceRabbitListenerEndpoint
- Parameters:
batchingStrategy
- the batching strategy.- See Also:
-
getAckMode
Description copied from interface:RabbitListenerEndpoint
Override the container factory'sAcknowledgeMode
.- Specified by:
getAckMode
in interfaceRabbitListenerEndpoint
- Returns:
- the acknowledgment mode.
-
setAckMode
-
getReplyPostProcessor
Description copied from interface:RabbitListenerEndpoint
Return aReplyPostProcessor
to post process a reply message before it is sent.- Specified by:
getReplyPostProcessor
in interfaceRabbitListenerEndpoint
- Returns:
- the post processor.
-
setReplyPostProcessor
Set aReplyPostProcessor
to post process a response message before it is sent.- Parameters:
replyPostProcessor
- the post processor.- Since:
- 2.2.5
-
getReplyContentType
Description copied from interface:RabbitListenerEndpoint
Get the reply content type.- Specified by:
getReplyContentType
in 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:RabbitListenerEndpoint
Return whether the content type set by a converter prevails or not.- Specified by:
isConverterWinsContentType
in 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:RabbitListenerEndpoint
Setup 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
queues
and themessageListener
to use but an implementation may override any default setting that was already set.- Specified by:
setupListenerContainer
in interfaceRabbitListenerEndpoint
- Parameters:
listenerContainer
- the listener container to configure
-
createMessageListener
Create aMessageListener
that is able to serve this endpoint for the specified container.- Parameters:
container
- theMessageListenerContainer
to create aMessageListener
.- Returns:
- a a
MessageListener
instance.
-
getEndpointDescription
- Returns:
- a description for this endpoint.
Available to subclasses, for inclusion in their
toString()
result.
-
toString
-