Annotation Interface Queue
@Documented
@Retention(RUNTIME)
@Target(METHOD)
@Executable(processOnStartup=true)
@MessageMapping
public @interface Queue
Binds a
Queue to a method for receiving or sending a Message.
Usage:
@JMSListener("myConnectionFactory")
public class Listener {
@Queue("my-queue")
public <T> void handle(@MessageBody T body, @MessageHeader(JMSHeaders.JMS_MESSAGE_ID) String messageID) {
// do some logic with body and messageID
}
@Queue(
value = "my-queue-2",
consumers = 5,
transacted = true
)
public <T> void handleConcurrently(@MessageBody T body, @MessageHeader("X-Arbitrary-Header") String arbitraryHeader) {
// do some logic with body and arbitraryHeader
}
}
- Since:
- 1.0.0
- Author:
- Elliott Pope
-
Required Element Summary
Required Elements -
Optional Element Summary
Optional ElementsModifier and TypeOptional ElementDescriptionintintThe number of consumers of the listener method, each with its own session, so that messages are handled concurrently.The delivery mode of the messages that a producer method sends.The name of aDeserializerin the bean context that a listener method uses to convert eachMessageof the queue into its@MessageBodyargument.Class<? extends JMSListenerErrorHandler>[]The error handlers to be injected into the message handling logic.intThe priority, from 0 (lowest) to 9, of the messages that a producer method sends.The name of aSerializerin the bean context to use to serialize an object into aMessagewhen sending.Class<? extends JMSListenerSuccessHandler>[]The success handlers to be injected into the message handling logic.booleanWhether the session is transacted.
-
Element Details
-
value
@AliasFor(annotation=io.micronaut.messaging.annotation.MessageMapping.class, member="value") String valueThe name of the queue to target.- Returns:
- the name
-
serializer
String serializerThe name of aSerializerin the bean context to use to serialize an object into aMessagewhen sending. If not specified, defaults toDefaultSerializerDeserializer.- Returns:
- the serializer bean name
- Default:
""
-
acknowledgeMode
-
transacted
boolean transactedWhether the session is transacted. The broker must support transacted sessions.On a listener, message receipt is transacted: the session is committed once the method returns and rolled back if it fails. On a producer method, each message is sent on a transacted session of its own, committed after the send. That transaction is the producer's own: a producer method called from a transacted listener does not join the listener's transaction, so its message is committed even if the listener's transaction is rolled back. To send in the listener's transaction, send with the listener's
Session.- Returns:
- true if transacted
- See Also:
- Default:
false
-
messageSelector
-
consumers
int consumersThe number of consumers of the listener method, each with its own session, so that messages are handled concurrently. The consumers share one connection. The listener bean is a single instance whose method is then called on several threads at once, so it must be thread-safe, and messages are no longer processed in the order they were sent. Ignored by producers.- Returns:
- the number of consumers
- Since:
- 5.2.0
- Default:
1
-
deliveryMode
JMSDeliveryMode deliveryModeThe delivery mode of the messages that a producer method sends. Ignored by listeners. AMessageDeliveryModeargument overrides it.- Returns:
- the delivery mode
- Since:
- 5.2.0
- Default:
PERSISTENT
-
priority
int priorityThe priority, from 0 (lowest) to 9, of the messages that a producer method sends. Ignored by listeners. AMessagePriorityargument overrides it.- Returns:
- the priority
- Since:
- 5.2.0
- Default:
4
-
deserializer
String deserializerThe name of aDeserializerin the bean context that a listener method uses to convert eachMessageof the queue into its@MessageBodyargument. If not specified, defaults toDefaultSerializerDeserializer.- Returns:
- the deserializer bean name
- Since:
- 5.2.0
- Default:
""
-
successHandlers
Class<? extends JMSListenerSuccessHandler>[] successHandlersThe success handlers to be injected into the message handling logic.- Returns:
- the classes of the success handlers to be added. These handlers must be present as
Singletoninstances. - Since:
- 3.0.0
- Default:
{}
-
errorHandlers
Class<? extends JMSListenerErrorHandler>[] errorHandlersThe error handlers to be injected into the message handling logic.- Returns:
- the classes of the error handlers to be added. These handlers must be present as
Singletoninstances. - Since:
- 3.0.0
- Default:
{}
-