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
  • Element Details

    • value

      @AliasFor(annotation=io.micronaut.messaging.annotation.MessageMapping.class, member="value") String value
      The name of the queue to target.
      Returns:
      the name
    • serializer

      String serializer
      The name of a Serializer in the bean context to use to serialize an object into a Message when sending. If not specified, defaults to DefaultSerializerDeserializer.
      Returns:
      the serializer bean name
      Default:
      ""
    • acknowledgeMode

      int acknowledgeMode
      Returns:
      the acknowledge mode for the JMSListener.
      See Also:
      • Session
      Default:
      1
    • transacted

      boolean transacted
      Whether 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:
      • Session
      Default:
      false
    • messageSelector

      String messageSelector
      Returns:
      the message selector for the queue
      Default:
      ""
    • consumers

      int consumers
      The 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 deliveryMode
      The delivery mode of the messages that a producer method sends. Ignored by listeners. A MessageDeliveryMode argument overrides it.
      Returns:
      the delivery mode
      Since:
      5.2.0
      Default:
      PERSISTENT
    • priority

      int priority
      The priority, from 0 (lowest) to 9, of the messages that a producer method sends. Ignored by listeners. A MessagePriority argument overrides it.
      Returns:
      the priority
      Since:
      5.2.0
      Default:
      4
    • deserializer

      String deserializer
      The name of a Deserializer in the bean context that a listener method uses to convert each Message of the queue into its @MessageBody argument. If not specified, defaults to DefaultSerializerDeserializer.
      Returns:
      the deserializer bean name
      Since:
      5.2.0
      Default:
      ""
    • successHandlers

      Class<? extends JMSListenerSuccessHandler>[] successHandlers
      The 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 Singleton instances.
      Since:
      3.0.0
      Default:
      {}
    • errorHandlers

      Class<? extends JMSListenerErrorHandler>[] errorHandlers
      The 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 Singleton instances.
      Since:
      3.0.0
      Default:
      {}