Class JMSObservations
java.lang.Object
io.micronaut.jms.observation.JMSObservations
The observers of the messages of a listener or a producer. An observer that fails with an exception is logged, so
that it does not stop a message from being processed or sent. One that fails with an
Error completes the
observations already started with it and rethrows it.- Since:
- 5.2.0
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidadd(Collection<? extends JMSMessageObserver> observers) static voidbeforeSend(List<JMSObservation> observations, jakarta.jms.Message message) Passes the message that is about to be sent to observations, in the order of their start.static voidcomplete(List<JMSObservation> observations, @Nullable Throwable error) Completes observations in the reverse order of their start.booleanisEmpty()process(JMSDestinationType destinationType, String destination, jakarta.jms.Message message) Starts the observations of a message that a listener processes.static io.micronaut.core.propagation.PropagatedContextpropagatedContext(List<JMSObservation> observations, io.micronaut.core.propagation.PropagatedContext context) Gives observations of a message that a listener processes, in the order of their start, the propagated context to process the message in.send(JMSDestinationType destinationType, String destination) Starts the observations of a message that a producer sends, before its connection is taken.
-
Constructor Details
-
JMSObservations
public JMSObservations()
-
-
Method Details
-
add
- Parameters:
observers- The observers to add
-
isEmpty
public boolean isEmpty()- Returns:
- Whether there are no observers
-
process
public List<JMSObservation> process(JMSDestinationType destinationType, String destination, jakarta.jms.Message message) Starts the observations of a message that a listener processes.- Parameters:
destinationType- The type of the destinationdestination- The name of the destinationmessage- The message- Returns:
- The started observations, to complete with
complete(List, Throwable)
-
send
Starts the observations of a message that a producer sends, before its connection is taken.- Parameters:
destinationType- The type of the destinationdestination- The name of the destination- Returns:
- The started observations, to pass the message to with
beforeSend(List, Message)and to complete withcomplete(List, Throwable)
-
beforeSend
Passes the message that is about to be sent to observations, in the order of their start.- Parameters:
observations- The observationsmessage- The message
-
propagatedContext
public static io.micronaut.core.propagation.PropagatedContext propagatedContext(List<JMSObservation> observations, io.micronaut.core.propagation.PropagatedContext context) Gives observations of a message that a listener processes, in the order of their start, the propagated context to process the message in.- Parameters:
observations- The observationscontext- The current propagated context- Returns:
- The propagated context to process the message in, the given one if no observation changes it
-
complete
Completes observations in the reverse order of their start. AnErrorof an observation is rethrown once the others are completed.- Parameters:
observations- The observationserror- The error, ornull
-