Package io.micronaut.jms.annotations
Annotation Interface Topic
@Documented
@Retention(RUNTIME)
@Target(METHOD)
@Executable(processOnStartup=true)
@MessageMapping
public @interface Topic
Annotation to bind a
Topic to a method for receiving or
sending a Message.
Usage:
@JMSListener("myConnectionFactory")
public class Listener {
@Topic("my-topic")
public <T> void handle(@Body T body, @Header(JMSHeaders.JMS_MESSAGE_ID) String messageID) {
// do some logic with body and messageID
}
@Topic("my-topic-2")
public <T> void handle(@Body T body, @Header("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 ElementDescriptionintClass<? extends JMSListenerErrorHandler>[]The error handlers to be injected into the message handling logic.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 message receipt is transacted.
-
Element Details
-
value
@AliasFor(annotation=io.micronaut.messaging.annotation.MessageMapping.class, member="value") String valueThe name of the topic 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
int acknowledgeMode- Returns:
- the acknowledge mode for the
JMSListener. - See Also:
-
Session
- Default:
- 1
-
transacted
boolean transactedWhether message receipt is transacted. The broker must support transacted sessions.- Returns:
- true if transacted
- See Also:
-
Session
- Default:
- false
-
messageSelector
String messageSelector- Returns:
- the message selector for the topic
- 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:
- {}
-