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 Details

    • AbstractRabbitListenerEndpoint

      public AbstractRabbitListenerEndpoint()
  • Method Details

    • setBeanFactory

      public void setBeanFactory(BeanFactory beanFactory) throws BeansException
      Specified by:
      setBeanFactory in interface BeanFactoryAware
      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 interface RabbitListenerEndpoint
      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

      public void setQueues(Queue... queues)
      Set the queues to use. Either the Queue instances or the queue names should be provided, but not both.
      Parameters:
      queues - to set.
      See Also:
    • 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 the Queue 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 exclusive boolean 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 interface RabbitListenerEndpoint
      Returns:
      the concurrency.
      Since:
      2.0
    • setAdmin

      public void setAdmin(AmqpAdmin admin)
      Set the AmqpAdmin instance to use.
      Parameters:
      admin - the AmqpAdmin instance.
    • getAdmin

      public AmqpAdmin getAdmin()
      Returns:
      the AmqpAdmin instance to use or null if none is configured.
    • getGroup

      public String getGroup()
      Specified by:
      getGroup in interface RabbitListenerEndpoint
      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 interface RabbitListenerEndpoint
      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 interface RabbitListenerEndpoint
      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 interface RabbitListenerEndpoint
      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 interface RabbitListenerEndpoint
      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 interface RabbitListenerEndpoint
      Parameters:
      batchListener - true for a batch listener.
      Since:
      2.2
      See Also:
    • getBatchingStrategy

      @Nullable public BatchingStrategy getBatchingStrategy()
    • setBatchingStrategy

      public void setBatchingStrategy(BatchingStrategy batchingStrategy)
      Description copied from interface: RabbitListenerEndpoint
      Set a BatchingStrategy to use when debatching messages.
      Specified by:
      setBatchingStrategy in interface RabbitListenerEndpoint
      Parameters:
      batchingStrategy - the batching strategy.
      See Also:
    • getAckMode

      @Nullable public AcknowledgeMode getAckMode()
      Description copied from interface: RabbitListenerEndpoint
      Override the container factory's AcknowledgeMode.
      Specified by:
      getAckMode in interface RabbitListenerEndpoint
      Returns:
      the acknowledgment mode.
    • setAckMode

      public void setAckMode(AcknowledgeMode mode)
    • getReplyPostProcessor

      public ReplyPostProcessor getReplyPostProcessor()
      Description copied from interface: RabbitListenerEndpoint
      Return a ReplyPostProcessor to post process a reply message before it is sent.
      Specified by:
      getReplyPostProcessor in interface RabbitListenerEndpoint
      Returns:
      the post processor.
    • setReplyPostProcessor

      public void setReplyPostProcessor(ReplyPostProcessor replyPostProcessor)
      Set a ReplyPostProcessor 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 interface RabbitListenerEndpoint
      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 interface RabbitListenerEndpoint
      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 the messageListener to use but an implementation may override any default setting that was already set.

      Specified by:
      setupListenerContainer in interface RabbitListenerEndpoint
      Parameters:
      listenerContainer - the listener container to configure
    • createMessageListener

      protected abstract MessageListener createMessageListener(MessageListenerContainer container)
      Create a MessageListener that is able to serve this endpoint for the specified container.
      Parameters:
      container - the MessageListenerContainer to create a MessageListener.
      Returns:
      a a MessageListener instance.
    • getEndpointDescription

      protected StringBuilder getEndpointDescription()
      Returns:
      a description for this endpoint.

      Available to subclasses, for inclusion in their toString() result.

    • toString

      public String toString()
      Overrides:
      toString in class Object