注释类型 JmsListener
@Target({METHOD,ANNOTATION_TYPE}) @Retention(RUNTIME) @Documented @Repeatable(JmsListeners.class) @MessageMapping public @interface JmsListener
Annotation that marks a method to be the target of a JMS message listener on the specifieddestination()
. ThecontainerFactory()
identifies theJmsListenerContainerFactory
to use to build the JMS listener container. If not set, a default container factory is assumed to be available with a bean name ofjmsListenerContainerFactory
unless an explicit default has been provided through configuration.Consider setting up a custom
DefaultJmsListenerContainerFactory
bean. For production purposes, you'll typically fine-tune timeouts and recovery settings. Most importantly, the default 'AUTO_ACKNOWLEDGE' mode does not provide reliability guarantees, so make sure to use transacted sessions in case of reliability needs.Processing of
@JmsListener
annotations is performed by registering aJmsListenerAnnotationBeanPostProcessor
. This can be done manually or, more conveniently, through the<jms:annotation-driven/>
element or@EnableJms
annotation.Annotated JMS listener methods are allowed to have flexible signatures similar to what
MessageMapping
provides:Session
to get access to the JMS sessionMessage
or one of its subclasses to get access to the raw JMS messageMessage
to use Spring's messaging abstraction counterpart@Payload
-annotated method arguments, including support for validation@Header
-annotated method arguments to extract specific header values, including standard JMS headers defined byJmsHeaders
@Headers
-annotated method argument that must also be assignable toMap
for obtaining access to all headersMessageHeaders
arguments for obtaining access to all headersMessageHeaderAccessor
orJmsMessageHeaderAccessor
for convenient access to all method arguments
Annotated methods may have a non-
void
return type. When they do, the result of the method invocation is sent as a JMS reply to the destination defined by theJMSReplyTO
header of the incoming message. If this header is not set, a default destination can be provided by adding@SendTo
to the method declaration.This annotation may be used as a meta-annotation to create custom composed annotations with attribute overrides.
- 从以下版本开始:
- 4.1
- 作者:
- Stephane Nicoll
- 另请参阅:
EnableJms
,JmsListenerAnnotationBeanPostProcessor
,JmsListeners
必需元素概要
所需元素 修饰符和类型 必需的元素 说明 String
destination
The destination name for this listener, resolved through the container-wideDestinationResolver
strategy.
可选元素概要
可选元素 修饰符和类型 可选元素 说明 String
concurrency
The concurrency limits for the listener, if any.String
containerFactory
The bean name of theJmsListenerContainerFactory
to use to create the message listener container responsible for serving this endpoint.String
id
The unique identifier of the container managing this endpoint.String
selector
The JMS message selector expression, if any.String
subscription
The name for the durable subscription, if any.
元素详细资料
destination
String destination
The destination name for this listener, resolved through the container-wideDestinationResolver
strategy.
containerFactory
String containerFactory
The bean name of theJmsListenerContainerFactory
to use to create the message listener container responsible for serving this endpoint.If not specified, the default container factory is used, if any.
- 默认值:
- ""
subscription
String subscription
The name for the durable subscription, if any.- 默认值:
- ""
concurrency
String concurrency
The concurrency limits for the listener, if any. Overrides the value defined by the container factory used to create the listener container.The concurrency limits can be a "lower-upper" String — for example, "5-10" — or a simple upper limit String — for example, "10", in which case the lower limit will be 1.
Note that the underlying container may or may not support all features. For instance, it may not be able to scale, in which case only the upper limit is used.
- 默认值:
- ""