Class JMSMetrics

java.lang.Object
io.micronaut.jms.metrics.JMSMetrics
All Implemented Interfaces:
io.micronaut.core.order.Ordered, JMSMessageObserver

@Singleton @Requires(classes=io.micrometer.core.instrument.MeterRegistry.class) @Requires(beans=io.micrometer.core.instrument.MeterRegistry.class) @Requires(property="micronaut.metrics.binders.jms.enabled",notEquals="false") public final class JMSMetrics extends Object implements JMSMessageObserver
Records the messages that JMS listeners process and that JMS producers send. Listener messages are counted as "jms.listener.messages" and timed as "jms.listener.duration", from the start of the listener method to the end of the success or error handlers. Producer messages are counted as "jms.producer.messages" and timed as "jms.producer.duration", from taking the connection to the commit of a transacted send, so a send that fails to connect is counted as a failure too. The meters are tagged with the destination and the result, success or failure, and failures with the exception class. Disable them with micronaut.metrics.binders.jms.enabled: false.
Since:
5.2.0
  • Field Details

    • ENABLED

      public static final String ENABLED
      The property that disables the metrics.
      See Also:
    • LISTENER_MESSAGES

      public static final String LISTENER_MESSAGES
      The name of the counter of the messages that listeners process.
      See Also:
    • LISTENER_DURATION

      public static final String LISTENER_DURATION
      The name of the timer of the messages that listeners process.
      See Also:
    • PRODUCER_MESSAGES

      public static final String PRODUCER_MESSAGES
      The name of the counter of the messages that producers send.
      See Also:
    • PRODUCER_DURATION

      public static final String PRODUCER_DURATION
      The name of the timer of the messages that producers send.
      See Also:
  • Method Details

    • process

      public JMSObservation process(JMSDestinationType destinationType, String destination, jakarta.jms.Message message)
      Description copied from interface: JMSMessageObserver
      Called before a listener processes a message: before the listener method and the success and error handlers.
      Specified by:
      process in interface JMSMessageObserver
      Parameters:
      destinationType - The type of the destination
      destination - The name of the destination the listener consumes from
      message - The message
      Returns:
      The observation to complete once the message is processed, or null
    • send

      public JMSObservation send(JMSDestinationType destinationType, String destination)
      Description copied from interface: JMSMessageObserver
      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's JMSObservation.beforeSend(Message) is called with it, so properties added to the message are sent with it.
      Specified by:
      send in interface JMSMessageObserver
      Parameters:
      destinationType - The type of the destination
      destination - 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
    • getOrder

      public int getOrder()
      Specified by:
      getOrder in interface io.micronaut.core.order.Ordered