Class RabbitListenerAnnotationBeanPostProcessor

java.lang.Object
org.springframework.amqp.listener.AbstractListenerAnnotationBeanPostProcessor<RabbitListener>
org.springframework.amqp.rabbit.annotation.RabbitListenerAnnotationBeanPostProcessor
All Implemented Interfaces:
org.springframework.beans.factory.Aware, org.springframework.beans.factory.BeanClassLoaderAware, org.springframework.beans.factory.BeanFactoryAware, org.springframework.beans.factory.config.BeanPostProcessor, org.springframework.beans.factory.SmartInitializingSingleton, org.springframework.context.EnvironmentAware, org.springframework.core.Ordered
Direct Known Subclasses:
MultiRabbitListenerAnnotationBeanPostProcessor

public class RabbitListenerAnnotationBeanPostProcessor extends org.springframework.amqp.listener.AbstractListenerAnnotationBeanPostProcessor<RabbitListener>
Bean post-processor that registers methods annotated with RabbitListener to be invoked by an AMQP message listener container created under the cover by a RabbitListenerContainerFactory according to the parameters of the annotation.

Annotated methods can use flexible arguments as defined by RabbitListener.

This post-processor is automatically registered by Spring's <rabbit:annotation-driven> XML element, and also by the EnableRabbit annotation.

Auto-detect any RabbitListenerConfigurer instances in the container, allowing for customization of the registry to be used, the default container factory or for fine-grained control over endpoint registrations. See EnableRabbit Javadoc for complete usage details.

Since:
1.4
See Also:
  • Field Details

  • Constructor Details

    • RabbitListenerAnnotationBeanPostProcessor

      public RabbitListenerAnnotationBeanPostProcessor()
  • Method Details

    • setEndpointRegistry

      public void setEndpointRegistry(RabbitListenerEndpointRegistry endpointRegistry)
      Set the RabbitListenerEndpointRegistry that will hold the created endpoint and manage the lifecycle of the related listener container.
      Parameters:
      endpointRegistry - the RabbitListenerEndpointRegistry to set.
    • setContainerFactoryBeanName

      public void setContainerFactoryBeanName(String containerFactoryBeanName)
      Set the name of the RabbitListenerContainerFactory to use by default.

      If none is specified, "rabbitListenerContainerFactory" is assumed to be defined.

      Parameters:
      containerFactoryBeanName - the RabbitListenerContainerFactory bean name.
    • setMessageHandlerMethodFactory

      public void setMessageHandlerMethodFactory(org.springframework.messaging.handler.annotation.support.MessageHandlerMethodFactory messageHandlerMethodFactory)
      Set the MessageHandlerMethodFactory to use to configure the message listener responsible to serve an endpoint detected by this processor.

      By default, DefaultMessageHandlerMethodFactory is used, and it can be configured further to support additional method arguments or to customize conversion and validation support. See DefaultMessageHandlerMethodFactory Javadoc for more details.

      Parameters:
      messageHandlerMethodFactory - the MessageHandlerMethodFactory instance.
    • setCharset

      public void setCharset(Charset charset)
      Set a charset for byte[] to String method argument conversion.
      Parameters:
      charset - the charset (default UTF-8).
      Since:
      2.2
    • setEnvironment

      public void setEnvironment(org.springframework.core.env.Environment environment)
      Specified by:
      setEnvironment in interface org.springframework.context.EnvironmentAware
      Overrides:
      setEnvironment in class org.springframework.amqp.listener.AbstractListenerAnnotationBeanPostProcessor<RabbitListener>
    • afterSingletonsInstantiated

      public void afterSingletonsInstantiated()
      Specified by:
      afterSingletonsInstantiated in interface org.springframework.beans.factory.SmartInitializingSingleton
      Overrides:
      afterSingletonsInstantiated in class org.springframework.amqp.listener.AbstractListenerAnnotationBeanPostProcessor<RabbitListener>
    • buildMetadata

      protected org.springframework.amqp.listener.AbstractListenerAnnotationBeanPostProcessor.TypeMetadata<RabbitListener> buildMetadata(Class<?> clazz)
      Specified by:
      buildMetadata in class org.springframework.amqp.listener.AbstractListenerAnnotationBeanPostProcessor<RabbitListener>
    • doProcessAmqpListener

      protected void doProcessAmqpListener(RabbitListener listenerAnnotation, Method method, Object bean, String beanName)
      Specified by:
      doProcessAmqpListener in class org.springframework.amqp.listener.AbstractListenerAnnotationBeanPostProcessor<RabbitListener>
    • processAmqpListener

      protected Collection<org.springframework.amqp.core.Declarable> processAmqpListener(RabbitListener rabbitListener, Method method, Object bean, String beanName)
    • processMultiMethodListeners

      protected void processMultiMethodListeners(List<RabbitListener> classLevelListeners, List<Method> multiMethods, Object bean, String beanName)
      Specified by:
      processMultiMethodListeners in class org.springframework.amqp.listener.AbstractListenerAnnotationBeanPostProcessor<RabbitListener>
    • processListener

      protected Collection<org.springframework.amqp.core.Declarable> processListener(MethodRabbitListenerEndpoint endpoint, RabbitListener rabbitListener, Object bean, Object target, String beanName)