Class JMSObservations

java.lang.Object
io.micronaut.jms.observation.JMSObservations

@Internal public final class JMSObservations extends Object
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 Details

    • JMSObservations

      public JMSObservations()
  • Method Details

    • add

      public void add(Collection<? extends JMSMessageObserver> observers)
      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 destination
      destination - The name of the destination
      message - The message
      Returns:
      The started observations, to complete with complete(List, Throwable)
    • send

      public List<JMSObservation> send(JMSDestinationType destinationType, String destination)
      Starts the observations of a message that a producer sends, before its connection is taken.
      Parameters:
      destinationType - The type of the destination
      destination - The name of the destination
      Returns:
      The started observations, to pass the message to with beforeSend(List, Message) and to complete with complete(List, Throwable)
    • beforeSend

      public static void beforeSend(List<JMSObservation> observations, jakarta.jms.Message message)
      Passes the message that is about to be sent to observations, in the order of their start.
      Parameters:
      observations - The observations
      message - 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 observations
      context - The current propagated context
      Returns:
      The propagated context to process the message in, the given one if no observation changes it
    • complete

      public static void complete(List<JMSObservation> observations, @Nullable Throwable error)
      Completes observations in the reverse order of their start. An Error of an observation is rethrown once the others are completed.
      Parameters:
      observations - The observations
      error - The error, or null