Class MethodAmqpListenerEndpoint

java.lang.Object
org.springframework.amqp.client.config.AbstractAmqpListenerEndpoint
org.springframework.amqp.client.config.MethodAmqpListenerEndpoint
All Implemented Interfaces:
AmqpListenerEndpoint

public class MethodAmqpListenerEndpoint extends AbstractAmqpListenerEndpoint
The AbstractAmqpListenerEndpoint implementation for POJO method invocation listener. Usually, instances of this class are created and handled by the framework.

The setMessageHandlerMethodFactory(MessageHandlerMethodFactory) and setBeanFactory(BeanFactory) must be provided before calling getMessageListener(). If other options have to be propagated to the AmqpMessagingListenerAdapter, they have to be provided prior to getMessageListener() call.

If this class is configured by the framework, any not provided options will be populated with default values from the MethodAmqpMessageListenerContainerFactory (if any).

Since:
4.1
  • Constructor Details

    • MethodAmqpListenerEndpoint

      public MethodAmqpListenerEndpoint(Object bean, Method method, String... addresses)
      Create an instance for the method to invoke on the provided bean. The addresses are propagated to the AmqpMessageListenerContainer.
      Parameters:
      bean - the bean to invoke the method on.
      method - the method to invoke.
      addresses - the addresses to listen to.
  • Method Details

    • setMessageHandlerMethodFactory

      public void setMessageHandlerMethodFactory(org.springframework.messaging.handler.annotation.support.MessageHandlerMethodFactory messageHandlerMethodFactory)
      Set the MessageHandlerMethodFactory to build an InvocableHandlerMethod for the listener method. Must be provided before calling getMessageListener(). Usually provided by the framework.
      Parameters:
      messageHandlerMethodFactory - the factory to use.
    • setDefaultRequeueRejected

      public void setDefaultRequeueRejected(boolean defaultRequeueRejected)
      Set the default behavior for messages rejection, for example, when the listener throws an exception. When true (default), messages will be requeued, otherwise - rejected. Setting to false causes all rejections to not be requeued. When set to true, the default can be overridden by the listener throwing an AmqpRejectAndDontRequeueException.
      Parameters:
      defaultRequeueRejected - false to reject messages by default.
      See Also:
    • isDefaultRequeueRejected

      protected boolean isDefaultRequeueRejected()
    • setReturnExceptions

      public void setReturnExceptions(boolean returnExceptions)
      Set whether exceptions thrown by the listener should be returned as a response message body to the sender using the normal replyTo/@SendTo semantics.
      Parameters:
      returnExceptions - true to return exceptions.
      See Also:
    • isReturnExceptions

      protected boolean isReturnExceptions()
    • setReplyPostProcessor

      public void setReplyPostProcessor(org.springframework.amqp.listener.adapter.ReplyPostProcessor replyPostProcessor)
      Set a ReplyPostProcessor to post process a response message before it is sent.
      Parameters:
      replyPostProcessor - the post-processor.
      See Also:
    • getReplyPostProcessor

      protected @Nullable org.springframework.amqp.listener.adapter.ReplyPostProcessor getReplyPostProcessor()
    • setErrorHandler

      public void setErrorHandler(AmqpListenerErrorHandler errorHandler)
      Set the AmqpListenerErrorHandler to invoke if the listener method throws an exception.
      Parameters:
      errorHandler - the error handler.
      See Also:
    • getErrorHandler

      protected @Nullable AmqpListenerErrorHandler getErrorHandler()
    • setReplyContentType

      public void setReplyContentType(String replyContentType)
      Set the reply content type. Overrides the one populated by a message converter.
      Parameters:
      replyContentType - the content type.
      See Also:
    • getReplyContentType

      protected @Nullable String getReplyContentType()
    • setHeaderMapper

      public void setHeaderMapper(org.springframework.amqp.support.AmqpHeaderMapper headerMapper)
      Set the AmqpHeaderMapper implementation to use to map the standard AMQP headers.
      Parameters:
      headerMapper - the AmqpHeaderMapper instance.
      See Also:
    • getHeaderMapper

      protected @Nullable org.springframework.amqp.support.AmqpHeaderMapper getHeaderMapper()
    • setMessageConverter

      public void setMessageConverter(org.springframework.amqp.support.converter.MessageConverter messageConverter)
      Set the converter to convert incoming messages to listener method arguments, and objects returned from listener methods for response messages.
      Parameters:
      messageConverter - The message converter.
      See Also:
    • getMessageConverter

      protected @Nullable org.springframework.amqp.support.converter.MessageConverter getMessageConverter()
    • setBeanFactory

      public void setBeanFactory(org.springframework.beans.factory.BeanFactory beanFactory)
      Provide a BeanFactory to use for resolving expressions in the listener method. Usually populated by the framework.
      Parameters:
      beanFactory - the BeanFactory to use.
    • getMessageListener

      public org.springframework.amqp.core.MessageListener getMessageListener()
      Description copied from interface: AmqpListenerEndpoint
      Return the message listener to be used in the target listener container bean.
      Returns:
      the message listener.