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:
MethodRabbitListenerEndpoint
,SimpleRabbitListenerEndpoint
-
-
Constructor Summary
Constructors Constructor Description AbstractRabbitListenerEndpoint()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract MessageListener
createMessageListener(MessageListenerContainer container)
Create aMessageListener
that is able to serve this endpoint for the specified container.AcknowledgeMode
getAckMode()
Override the container factory'sAcknowledgeMode
.AmqpAdmin
getAdmin()
Boolean
getAutoStartup()
Override of the default autoStartup property.BatchingStrategy
getBatchingStrategy()
protected BeanExpressionContext
getBeanExpressionContext()
protected BeanFactory
getBeanFactory()
protected BeanResolver
getBeanResolver()
String
getConcurrency()
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
getEndpointDescription()
String
getGroup()
String
getId()
MessageConverter
getMessageConverter()
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.Integer
getPriority()
Collection<String>
getQueueNames()
Collection<Queue>
getQueues()
String
getReplyContentType()
Get the reply content type.ReplyPostProcessor
getReplyPostProcessor()
Return aReplyPostProcessor
to post process a reply message before it is sent.protected BeanExpressionResolver
getResolver()
TaskExecutor
getTaskExecutor()
Get the task executor to use for this endpoint's listener container.boolean
isBatchListener()
boolean
isConverterWinsContentType()
Return whether the content type set by a converter prevails or not.boolean
isExclusive()
void
setAckMode(AcknowledgeMode mode)
void
setAdmin(AmqpAdmin admin)
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
setGroup(String group)
Set the group for the corresponding listener container.void
setId(String id)
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
setQueues(Queue... queues)
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.String
toString()
-
-
-
Method Detail
-
setBeanFactory
public void setBeanFactory(BeanFactory beanFactory) throws BeansException
- Specified by:
setBeanFactory
in interfaceBeanFactoryAware
- Throws:
BeansException
-
getBeanFactory
@Nullable protected BeanFactory getBeanFactory()
-
getResolver
protected BeanExpressionResolver getResolver()
-
getBeanResolver
protected BeanResolver getBeanResolver()
-
getBeanExpressionContext
protected BeanExpressionContext getBeanExpressionContext()
-
setId
public void setId(String id)
-
getId
public String 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:
RabbitListenerContainerFactory.createListenerContainer(org.springframework.amqp.rabbit.listener.RabbitListenerEndpoint)
-
setQueues
public void setQueues(Queue... queues)
Set the queues to use. Either theQueue
instances or the queue names should be provided, but not both.- Parameters:
queues
- to set.- See Also:
setQueueNames(java.lang.String...)
-
getQueues
public Collection<Queue> getQueues()
- Returns:
- the queues for this endpoint.
-
getQueueNames
public Collection<String> getQueueNames()
- Returns:
- the queue names for this endpoint.
-
setQueueNames
public void setQueueNames(String... queueNames)
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:
setQueues(org.springframework.amqp.core.Queue...)
-
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
public void setPriority(Integer priority)
Set the priority of this endpoint.- Parameters:
priority
- the priority value.
-
getPriority
public Integer getPriority()
- Returns:
- the priority of this endpoint or
null
if no priority is set.
-
setConcurrency
public void setConcurrency(String concurrency)
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
public String 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
public void setAdmin(AmqpAdmin admin)
Set theAmqpAdmin
instance to use.- Parameters:
admin
- theAmqpAdmin
instance.
-
getAdmin
public AmqpAdmin getAdmin()
- Returns:
- the
AmqpAdmin
instance to use ornull
if none is configured.
-
getGroup
public String getGroup()
- Specified by:
getGroup
in interfaceRabbitListenerEndpoint
- Returns:
- the group of this endpoint or null if not in a group.
-
setGroup
public void setGroup(String group)
Set the group for the corresponding listener container.- Parameters:
group
- the group.- Since:
- 1.5
-
setAutoStartup
public void setAutoStartup(Boolean autoStartup)
Override the default autoStartup property.- Parameters:
autoStartup
- the autoStartup.- Since:
- 2.0
-
getAutoStartup
public Boolean getAutoStartup()
Description copied from interface:RabbitListenerEndpoint
Override of the default autoStartup property.- Specified by:
getAutoStartup
in interfaceRabbitListenerEndpoint
- Returns:
- the autoStartup.
-
getMessageConverter
public MessageConverter 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
public void setMessageConverter(MessageConverter messageConverter)
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
public TaskExecutor 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
public void setTaskExecutor(TaskExecutor taskExecutor)
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:
setBatchListener
in interfaceRabbitListenerEndpoint
- Parameters:
batchListener
- true for a batch listener.- Since:
- 2.2
- See Also:
setBatchingStrategy(BatchingStrategy)
-
getBatchingStrategy
@Nullable public BatchingStrategy getBatchingStrategy()
-
setBatchingStrategy
public void setBatchingStrategy(BatchingStrategy batchingStrategy)
Description copied from interface:RabbitListenerEndpoint
Set aBatchingStrategy
to use when debatching messages.- Specified by:
setBatchingStrategy
in interfaceRabbitListenerEndpoint
- Parameters:
batchingStrategy
- the batching strategy.- See Also:
RabbitListenerEndpoint.setBatchListener(boolean)
-
getAckMode
@Nullable public AcknowledgeMode getAckMode()
Description copied from interface:RabbitListenerEndpoint
Override the container factory'sAcknowledgeMode
.- Specified by:
getAckMode
in interfaceRabbitListenerEndpoint
- Returns:
- the acknowledgment mode.
-
setAckMode
public void setAckMode(AcknowledgeMode mode)
-
getReplyPostProcessor
public ReplyPostProcessor 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
public void setReplyPostProcessor(ReplyPostProcessor replyPostProcessor)
Set aReplyPostProcessor
to post process a response message before it is sent.- Parameters:
replyPostProcessor
- the post processor.- Since:
- 2.2.5
-
getReplyContentType
public String getReplyContentType()
Description copied from interface:RabbitListenerEndpoint
Get the reply content type.- Specified by:
getReplyContentType
in interfaceRabbitListenerEndpoint
- Returns:
- the content type.
-
setReplyContentType
public void setReplyContentType(String replyContentType)
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
public void setupListenerContainer(MessageListenerContainer listenerContainer)
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
protected abstract MessageListener createMessageListener(MessageListenerContainer container)
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
protected StringBuilder getEndpointDescription()
- Returns:
- a description for this endpoint.
Available to subclasses, for inclusion in their
toString()
result.
-
-