Interface JMSMessageObserver
- All Superinterfaces:
io.micronaut.core.order.Ordered
- All Known Implementing Classes:
JMSMetrics, JMSTracing
public interface JMSMessageObserver
extends io.micronaut.core.order.Ordered
Observes the messages that JMS listeners process and that JMS producers send, for example to record metrics or
traces. Each observer bean is called before a message is processed or sent, and completes the observation that it
returns afterwards. Observers are called in
order and their observations are completed in the
reverse order. An observer that throws an exception is logged and skipped. One that throws an Error stops
the processing or the send: the observations already started are completed with the error, which is rethrown.- Since:
- 5.2.0
-
Field Summary
Fields inherited from interface io.micronaut.core.order.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE -
Method Summary
Modifier and TypeMethodDescriptiondefault @Nullable JMSObservationprocess(JMSDestinationType destinationType, String destination, jakarta.jms.Message message) Called before a listener processes a message: before the listener method and the success and error handlers.default @Nullable JMSObservationsend(JMSDestinationType destinationType, String destination) Called before a producer sends a message, before the connection is taken from the pool and the message is created, so a send that fails to connect is observed too.Methods inherited from interface io.micronaut.core.order.Ordered
getOrder
-
Method Details
-
process
default @Nullable JMSObservation process(JMSDestinationType destinationType, String destination, jakarta.jms.Message message) Called before a listener processes a message: before the listener method and the success and error handlers.- Parameters:
destinationType- The type of the destinationdestination- The name of the destination the listener consumes frommessage- The message- Returns:
- The observation to complete once the message is processed, or
null
-
send
Called before a producer sends a message, before the connection is taken from the pool and the message is created, so a send that fails to connect is observed too. Once the message is created and its headers are set, the observation'sJMSObservation.beforeSend(Message)is called with it, so properties added to the message are sent with it.- Parameters:
destinationType- The type of the destinationdestination- The name of the destination the message is sent to- Returns:
- The observation to complete once the message is sent or the send failed, or
null
-