Class 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
RabbitListener
to be invoked by a 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 endpoints registration. See
EnableRabbit Javadoc for complete usage details.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe bean name of the defaultRabbitListenerContainerFactory.static final StringFields inherited from interface org.springframework.core.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidprotected voidintgetOrder()protected StringnoBeanFoundMessage(Object target, String listenerBeanName, String requestedBeanName, Class<?> expectedClass) postProcessAfterInitialization(Object bean, String beanName) postProcessBeforeInitialization(Object bean, String beanName) protected Collection<org.springframework.amqp.core.Declarable>processAmqpListener(RabbitListener rabbitListener, Method method, Object bean, String beanName) protected Collection<org.springframework.amqp.core.Declarable>processListener(MethodRabbitListenerEndpoint endpoint, RabbitListener rabbitListener, Object bean, Object target, String beanName) protected StringresolveExpressionAsString(String value, String attribute) voidsetBeanClassLoader(ClassLoader classLoader) voidsetBeanFactory(org.springframework.beans.factory.BeanFactory beanFactory) Making aBeanFactoryavailable is optional; if not set,RabbitListenerConfigurerbeans won't get autodetected and anendpoint registryhas to be explicitly configured.voidsetCharset(Charset charset) Set a charset for byte[] to String method argument conversion.voidsetContainerFactoryBeanName(String containerFactoryBeanName) Set the name of theRabbitListenerContainerFactoryto use by default.voidsetEndpointRegistry(RabbitListenerEndpointRegistry endpointRegistry) Set theRabbitListenerEndpointRegistrythat will hold the created endpoint and manage the lifecycle of the related listener container.voidsetEnvironment(org.springframework.core.env.Environment environment) voidsetMessageHandlerMethodFactory(org.springframework.messaging.handler.annotation.support.MessageHandlerMethodFactory messageHandlerMethodFactory) Set theMessageHandlerMethodFactoryto use to configure the message listener responsible to serve an endpoint detected by this processor.
-
Field Details
-
DEFAULT_RABBIT_LISTENER_CONTAINER_FACTORY_BEAN_NAME
The bean name of the defaultRabbitListenerContainerFactory.- See Also:
-
RABBIT_EMPTY_STRING_ARGUMENTS_PROPERTY
- See Also:
-
-
Constructor Details
-
RabbitListenerAnnotationBeanPostProcessor
public RabbitListenerAnnotationBeanPostProcessor()
-
-
Method Details
-
getOrder
public int getOrder()- Specified by:
getOrderin interfaceorg.springframework.core.Ordered
-
setEndpointRegistry
Set theRabbitListenerEndpointRegistrythat will hold the created endpoint and manage the lifecycle of the related listener container.- Parameters:
endpointRegistry- theRabbitListenerEndpointRegistryto set.
-
setContainerFactoryBeanName
Set the name of theRabbitListenerContainerFactoryto use by default.If none is specified, "rabbitListenerContainerFactory" is assumed to be defined.
- Parameters:
containerFactoryBeanName- theRabbitListenerContainerFactorybean name.
-
setMessageHandlerMethodFactory
public void setMessageHandlerMethodFactory(org.springframework.messaging.handler.annotation.support.MessageHandlerMethodFactory messageHandlerMethodFactory) Set theMessageHandlerMethodFactoryto use to configure the message listener responsible to serve an endpoint detected by this processor.By default,
DefaultMessageHandlerMethodFactoryis used and it can be configured further to support additional method arguments or to customize conversion and validation support. SeeDefaultMessageHandlerMethodFactoryJavadoc for more details.- Parameters:
messageHandlerMethodFactory- theMessageHandlerMethodFactoryinstance.
-
setBeanFactory
public void setBeanFactory(org.springframework.beans.factory.BeanFactory beanFactory) Making aBeanFactoryavailable is optional; if not set,RabbitListenerConfigurerbeans won't get autodetected and anendpoint registryhas to be explicitly configured.- Specified by:
setBeanFactoryin interfaceorg.springframework.beans.factory.BeanFactoryAware- Parameters:
beanFactory- theBeanFactoryto be used.
-
setBeanClassLoader
- Specified by:
setBeanClassLoaderin interfaceorg.springframework.beans.factory.BeanClassLoaderAware
-
setEnvironment
public void setEnvironment(org.springframework.core.env.Environment environment) - Specified by:
setEnvironmentin interfaceorg.springframework.context.EnvironmentAware
-
setCharset
Set a charset for byte[] to String method argument conversion.- Parameters:
charset- the charset (default UTF-8).- Since:
- 2.2
-
afterSingletonsInstantiated
public void afterSingletonsInstantiated()- Specified by:
afterSingletonsInstantiatedin interfaceorg.springframework.beans.factory.SmartInitializingSingleton
-
postProcessBeforeInitialization
public Object postProcessBeforeInitialization(Object bean, String beanName) throws org.springframework.beans.BeansException - Specified by:
postProcessBeforeInitializationin interfaceorg.springframework.beans.factory.config.BeanPostProcessor- Throws:
org.springframework.beans.BeansException
-
postProcessAfterInitialization
public Object postProcessAfterInitialization(Object bean, String beanName) throws org.springframework.beans.BeansException - Specified by:
postProcessAfterInitializationin interfaceorg.springframework.beans.factory.config.BeanPostProcessor- Throws:
org.springframework.beans.BeansException
-
processAmqpListener
protected Collection<org.springframework.amqp.core.Declarable> processAmqpListener(RabbitListener rabbitListener, Method method, Object bean, String beanName) -
processListener
protected Collection<org.springframework.amqp.core.Declarable> processListener(MethodRabbitListenerEndpoint endpoint, RabbitListener rabbitListener, Object bean, Object target, String beanName) -
assertBeanFactory
protected void assertBeanFactory() -
noBeanFoundMessage
-
resolveExpressionAsString
-