@Target(value={METHOD,ANNOTATION_TYPE}) @Retention(value=RUNTIME) @MessageMapping @Documented public @interface RabbitListener
queues(). The containerFactory()
identifies the RabbitListenerContainerFactory to use to build the rabbit listener container. If not
set, a default container factory is assumed to be available with a bean
name of rabbitListenerContainerFactory unless an explicit default has been
provided through configuration.
Processing of @RabbitListener annotations is performed by
registering a RabbitListenerAnnotationBeanPostProcessor. This can be
done manually or, more conveniently, through the <rabbit:annotation-driven/>
element or EnableRabbit annotation.
Annotated methods are allowed to have flexible signatures similar to what
MessageMapping provides, that is
Channel to get access to the ChannelMessage or one if subclass to get
access to the raw AMQP messageMessage to use the messaging abstraction counterpart@Payload-annotated method
arguments including the support of validation@Header-annotated method
arguments to extract a specific header value, including standard AMQP headers defined by
AmqpHeaders@Headers-annotated
argument that must also be assignable to Map for getting access to all
headers.MessageHeaders arguments for
getting access to all headers.MessageHeaderAccessor
or AmqpMessageHeaderAccessor
for convenient access to all method arguments.Annotated method may have a non void return type. When they do, the result of the
method invocation is sent as a reply to the queue defined by the
ReplyTo header of the
incoming message. When this value is not set, a default queue can be provided by
adding @SendTo to the method
declaration.
EnableRabbit,
RabbitListenerAnnotationBeanPostProcessor| Modifier and Type | Required Element and Description |
|---|---|
String[] |
queues
The queues for this listener.
|
| Modifier and Type | Optional Element and Description |
|---|---|
String |
admin
Reference to a
RabbitAdmin. |
String |
containerFactory
The bean name of the
RabbitListenerContainerFactory
to use to create the message listener container responsible to serve this endpoint. |
boolean |
exclusive
When
true, a single consumer in the container will have exclusive use of the
queues(), preventing other consumers from receiving messages from the
queues. |
String |
id
The unique identifier of the container managing for this endpoint.
|
String |
priority
The priority of this endpoint.
|
public abstract String[] queues
Queue object.MessageListenerContainer.public abstract String id
If none is specified an auto-generated one is provided.
id for the container managing for this endpoint.RabbitListenerEndpointRegistry.getListenerContainer(String)public abstract String containerFactory
RabbitListenerContainerFactory
to use to create the message listener container responsible to serve this endpoint.
If not specified, the default container factory is used, if any.
RabbitListenerContainerFactory
bean name.public abstract boolean exclusive
true, a single consumer in the container will have exclusive use of the
queues(), preventing other consumers from receiving messages from the
queues. When true, requires a concurrency of 1. Default false.exclusive boolean flag.public abstract String priority
public abstract String admin
RabbitAdmin. Required if the listener is using auto-delete
queues and those queues are configured for conditional declaration. This
is the admin that will (re)declare those queues when the container is
(re)started. See the reference documentation for more information.RabbitAdmin bean name.