Annotation Interface AmqpListener
addresses().
The containerFactory() identifies the
MethodAmqpMessageListenerContainerFactory
to build an AMQP listener container.
If not set, a default container factory is assumed to be available with a bean name
AmqpDefaultConfiguration.DEFAULT_AMQP_LISTENER_CONTAINER_FACTORY_BEAN_NAME.
Processing of @AmqpListener annotations is performed by registering a
AmqpListenerAnnotationBeanPostProcessor. This can be done manually or, more
conveniently, through the EnableAmqp annotation.
Annotated methods are allowed to have flexible signatures similar to what
MessageMapping provides, that is
MessageMessageto use the messaging abstraction counterpartPayload-annotated method arguments including the support of validationHeader-annotated method arguments to extract a specific header value, including standard AMQP headers defined byAmqpHeadersHeaders-annotated argument that must also be assignable toMapfor getting access to all headers.MessageHeadersarguments for getting access to all headers.MessageHeaderAccessororAmqpMessageHeaderAccessorfor convenient access to all method arguments.AmqpAcknowledgment- a convenient abstraction for manual acks.Delivery- native ProtonJ delivery container for low-level API.
Annotated methods 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.
- Since:
- 4.1
- See Also:
-
Optional Element Summary
Optional ElementsModifier and TypeOptional ElementDescriptionString[]The AMQP 1.0 addresses to listen to.String[]TheAdvicebean names to apply to the listener container.Override the container factoryautoAcceptproperty.Set tofalseto not auto start, to override the default setting in the container factory.Set the concurrency of the listener container for this listener.The bean name of theMethodAmqpMessageListenerContainerFactoryto use to create the message listener container responsible to serve this endpoint.Set the default behavior for messages rejection.Set anAmqpListenerErrorHandlerto invoke if the listener method throws an exception.Set the task executor bean name to use for the listener container; overrides any executor set on the container factory.A duration for how long to wait for all the consumers to shut down successfully on listener container stop.Override the container factory'sheaderMapperused for this listener.The unique identifier of the container managing for this endpoint.The initial number of credits to grant to the AMQP receiver.Override the container factory's message converter used for this listener.The timeout for deliveries from the broker in the target AMQP consumer.Used to set the content-type of a reply message.The bean name of aReplyPostProcessorto post process a response before it is sent.trueto cause exceptions thrown by the listener to be sent to the sender using normalreplyTo/@SendTosemantics.
-
Element Details
-
id
String idThe unique identifier of the container managing for this endpoint.If none is specified, an auto-generated one is provided.
- Returns:
- the
idfor the container managing for this endpoint.
- Default:
""
-
containerFactory
String containerFactoryThe bean name of theMethodAmqpMessageListenerContainerFactoryto use to create the message listener container responsible to serve this endpoint.If not specified, the default container factory is used, if any. If a SpEL expression is provided (
#{...}), the expression can either evaluate to a container factory instance or a bean name.- Returns:
- the
MethodAmqpMessageListenerContainerFactorybean name.
- Default:
""
-
addresses
String[] addressesThe AMQP 1.0 addresses to listen to. The entries can be 'queue name', 'property-placeholder keys' or 'expressions'. Each expression must be resolved to the address. The addresses must exist.- Returns:
- the addresses or expressions (SpEL) for the target listener container to listen from.
- See Also:
- Default:
{}
-
initialCredits
String initialCreditsThe initial number of credits to grant to the AMQP receiver. Can be SpEL expression or properties placeholder-based. Evaluates toint.- Returns:
- the initial number of credits to grant to the AMQP receiver.
- Default:
""
-
returnExceptions
String returnExceptionstrueto cause exceptions thrown by the listener to be sent to the sender using normalreplyTo/@SendTosemantics. Whenfalse, the exception is thrown to the listener container and retry/DLQ processing could be performed on the AMQP broker side. Overrides the default set by the listener container factory.- Returns:
trueto return exceptions. If the client side uses aRemoteInvocationAwareMessageConverterAdapterthe exception will be re-thrown. Otherwise, the sender will receive aRemoteInvocationResultwrapping the exception.
- Default:
""
-
defaultRequeueRejected
String defaultRequeueRejectedSet the default behavior for messages rejection. Overrides the default set by the listener container factory. Can be SpEL or properties placeholder-based; evaluates toboolean.- Returns:
- the default flag for messages rejection.
- Default:
""
-
errorHandler
String errorHandlerSet anAmqpListenerErrorHandlerto invoke if the listener method throws an exception. Overrides the default set by the listener container factory. A simple String representing the bean name. If a SpEL expression (#{...}) is provided, the expression must evaluate to a bean name or aAmqpListenerErrorHandlerinstance.- Returns:
- the error handler.
- Default:
""
-
concurrency
String concurrencySet the concurrency of the listener container for this listener. Overrides the default set by the listener container factory. Maps to the concurrency setting of the container type.- Returns:
- the concurrency.
- Default:
""
-
autoStartup
String autoStartupSet tofalseto not auto start, to override the default setting in the container factory.- Returns:
falseto not auto start.
- Default:
""
-
executor
String executorSet the task executor bean name to use for the listener container; overrides any executor set on the container factory. If a SpEL expression is provided (#{...}), the expression can either evaluate to an executor instance or a bean name.- Returns:
- the executor bean name.
- Default:
""
-
autoAccept
String autoAcceptOverride the container factoryautoAcceptproperty. If a SpEL expression is provided, it must evaluate to aboolean. If the listener method is asynchronous (CompletableFuture,reactor.core.publisher.Monoor Kotlinsuspendfunction), this option is overridden tofalseby the targetAmqpMessageListenerContainer.- Returns:
- the autoAccept flag.
- Default:
""
-
replyPostProcessor
String replyPostProcessorThe bean name of aReplyPostProcessorto post process a response before it is sent. If a SpEL expression is provided (#{...}), the expression can either evaluate to a post-processor instance or a bean name.- Returns:
- the bean name.
- See Also:
- Default:
""
-
messageConverter
String messageConverterOverride the container factory's message converter used for this listener. If a SpEL expression is provided (#{...}), the expression can either evaluate to a converter instance or a bean name.- Returns:
- the message converter bean name.
- Default:
""
-
headerMapper
String headerMapperOverride the container factory'sheaderMapperused for this listener. If a SpEL expression is provided (#{...}), the expression can either evaluate to a header mapper instance or a bean name.- Returns:
- the header mapper bean name.
- Default:
""
-
replyContentType
String replyContentTypeUsed to set the content-type of a reply message. Useful when used in conjunction with message converters that can handle multiple content types, such as theContentTypeDelegatingMessageConverter. SpEL expressions and property placeholders are supported. Also, useful for controlling the final content type property when used with certain converters. This does not apply when the return type isMessageorMessage; the content-type must be set on the respective message property or header, in those cases.- Returns:
- the content type.
- Default:
""
-
receiveTimeout
String receiveTimeoutThe timeout for deliveries from the broker in the target AMQP consumer. Can be SpEL expression or properties placeholder-based. Evaluates tolongrepresenting milliseconds; or ISO 8601Durationformat.- Returns:
- the timeout for deliveries from the broker in the target AMQP consumer.
- Default:
""
-
gracefulShutdownPeriod
String gracefulShutdownPeriodA duration for how long to wait for all the consumers to shut down successfully on listener container stop. Can be SpEL expression or properties placeholder-based. Evaluates tolongrepresenting milliseconds; or ISO 8601Durationformat.- Returns:
- the duration for how long to wait for all the consumers to shut down.
- Default:
""
-
adviceChain
String[] adviceChainTheAdvicebean names to apply to the listener container.- Returns:
- the
Advicebean names to apply to the listener container. - See Also:
- Default:
{}
-