public class RabbitListenerAnnotationBeanPostProcessor extends Object implements BeanPostProcessor, Ordered, BeanFactoryAware, BeanClassLoaderAware, EnvironmentAware, SmartInitializingSingleton
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.
RabbitListener,
EnableRabbit,
RabbitListenerConfigurer,
RabbitListenerEndpointRegistrar,
RabbitListenerEndpointRegistry,
RabbitListenerEndpoint,
MethodRabbitListenerEndpoint| Modifier and Type | Field and Description |
|---|---|
static String |
DEFAULT_RABBIT_LISTENER_CONTAINER_FACTORY_BEAN_NAME
The bean name of the default
RabbitListenerContainerFactory. |
static String |
RABBIT_EMPTY_STRING_ARGUMENTS_PROPERTY |
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE| Constructor and Description |
|---|
RabbitListenerAnnotationBeanPostProcessor() |
| Modifier and Type | Method and Description |
|---|---|
void |
afterSingletonsInstantiated() |
protected void |
assertBeanFactory() |
int |
getOrder() |
protected String |
noBeanFoundMessage(Object target,
String listenerBeanName,
String requestedBeanName,
Class<?> expectedClass) |
Object |
postProcessAfterInitialization(Object bean,
String beanName) |
Object |
postProcessBeforeInitialization(Object bean,
String beanName) |
protected Collection<Declarable> |
processAmqpListener(RabbitListener rabbitListener,
Method method,
Object bean,
String beanName) |
protected Collection<Declarable> |
processListener(MethodRabbitListenerEndpoint endpoint,
RabbitListener rabbitListener,
Object bean,
Object target,
String beanName) |
protected String |
resolveExpressionAsString(String value,
String attribute) |
void |
setBeanClassLoader(ClassLoader classLoader) |
void |
setBeanFactory(BeanFactory beanFactory)
Making a
BeanFactory available is optional; if not set,
RabbitListenerConfigurer beans won't get autodetected and an
endpoint registry has to be explicitly configured. |
void |
setCharset(Charset charset)
Set a charset for byte[] to String method argument conversion.
|
void |
setContainerFactoryBeanName(String containerFactoryBeanName)
Set the name of the
RabbitListenerContainerFactory to use by default. |
void |
setEndpointRegistry(RabbitListenerEndpointRegistry endpointRegistry)
Set the
RabbitListenerEndpointRegistry that will hold the created
endpoint and manage the lifecycle of the related listener container. |
void |
setEnvironment(Environment environment) |
void |
setMessageHandlerMethodFactory(MessageHandlerMethodFactory messageHandlerMethodFactory)
Set the
MessageHandlerMethodFactory to use to configure the message
listener responsible to serve an endpoint detected by this processor. |
public static final String DEFAULT_RABBIT_LISTENER_CONTAINER_FACTORY_BEAN_NAME
RabbitListenerContainerFactory.public static final String RABBIT_EMPTY_STRING_ARGUMENTS_PROPERTY
public RabbitListenerAnnotationBeanPostProcessor()
public void setEndpointRegistry(RabbitListenerEndpointRegistry endpointRegistry)
RabbitListenerEndpointRegistry that will hold the created
endpoint and manage the lifecycle of the related listener container.endpointRegistry - the RabbitListenerEndpointRegistry to set.public void setContainerFactoryBeanName(String containerFactoryBeanName)
RabbitListenerContainerFactory to use by default.
If none is specified, "rabbitListenerContainerFactory" is assumed to be defined.
containerFactoryBeanName - the RabbitListenerContainerFactory bean name.public void setMessageHandlerMethodFactory(MessageHandlerMethodFactory messageHandlerMethodFactory)
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.
messageHandlerMethodFactory - the MessageHandlerMethodFactory instance.public void setBeanFactory(BeanFactory beanFactory)
BeanFactory available is optional; if not set,
RabbitListenerConfigurer beans won't get autodetected and an
endpoint registry has to be explicitly configured.setBeanFactory in interface BeanFactoryAwarebeanFactory - the BeanFactory to be used.public void setBeanClassLoader(ClassLoader classLoader)
setBeanClassLoader in interface BeanClassLoaderAwarepublic void setEnvironment(Environment environment)
setEnvironment in interface EnvironmentAwarepublic void setCharset(Charset charset)
charset - the charset (default UTF-8).public void afterSingletonsInstantiated()
afterSingletonsInstantiated in interface SmartInitializingSingletonpublic Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException
postProcessBeforeInitialization in interface BeanPostProcessorBeansExceptionpublic Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException
postProcessAfterInitialization in interface BeanPostProcessorBeansExceptionprotected Collection<Declarable> processAmqpListener(RabbitListener rabbitListener, Method method, Object bean, String beanName)
protected Collection<Declarable> processListener(MethodRabbitListenerEndpoint endpoint, RabbitListener rabbitListener, Object bean, Object target, String beanName)
protected void assertBeanFactory()
protected String noBeanFoundMessage(Object target, String listenerBeanName, String requestedBeanName, Class<?> expectedClass)