Class AbstractMetricsCollector

java.lang.Object
com.rabbitmq.client.impl.AbstractMetricsCollector
All Implemented Interfaces:
MetricsCollector
Direct Known Subclasses:
MicrometerMetricsCollector, OpenTelemetryMetricsCollector, StandardMetricsCollector

public abstract class AbstractMetricsCollector extends Object implements MetricsCollector
Base class for MetricsCollector. Implements tricky logic such as keeping track of acknowledged and rejected messages. Sub-classes just need to implement the logic to increment their metrics. Note transactions are not supported (see MetricsCollector.
See Also:
  • Constructor Details

    • AbstractMetricsCollector

      public AbstractMetricsCollector()
  • Method Details

    • newConnection

      public void newConnection(Connection connection)
      Specified by:
      newConnection in interface MetricsCollector
    • closeConnection

      public void closeConnection(Connection connection)
      Specified by:
      closeConnection in interface MetricsCollector
    • newChannel

      public void newChannel(Channel channel)
      Specified by:
      newChannel in interface MetricsCollector
    • closeChannel

      public void closeChannel(Channel channel)
      Specified by:
      closeChannel in interface MetricsCollector
    • basicPublish

      public void basicPublish(Channel channel)
      Specified by:
      basicPublish in interface MetricsCollector
    • basicPublishFailure

      public void basicPublishFailure(Channel channel, Throwable cause)
      Specified by:
      basicPublishFailure in interface MetricsCollector
    • basicPublishAck

      public void basicPublishAck(Channel channel, long deliveryTag, boolean multiple)
      Specified by:
      basicPublishAck in interface MetricsCollector
    • basicPublishNack

      public void basicPublishNack(Channel channel, long deliveryTag, boolean multiple)
      Specified by:
      basicPublishNack in interface MetricsCollector
    • basicPublishUnrouted

      public void basicPublishUnrouted(Channel channel)
      Specified by:
      basicPublishUnrouted in interface MetricsCollector
    • basicConsume

      public void basicConsume(Channel channel, String consumerTag, boolean autoAck)
      Specified by:
      basicConsume in interface MetricsCollector
    • basicCancel

      public void basicCancel(Channel channel, String consumerTag)
      Specified by:
      basicCancel in interface MetricsCollector
    • consumedMessage

      public void consumedMessage(Channel channel, long deliveryTag, boolean autoAck)
      Specified by:
      consumedMessage in interface MetricsCollector
    • consumedMessage

      public void consumedMessage(Channel channel, long deliveryTag, String consumerTag)
      Specified by:
      consumedMessage in interface MetricsCollector
    • basicAck

      public void basicAck(Channel channel, long deliveryTag, boolean multiple)
      Specified by:
      basicAck in interface MetricsCollector
    • basicNack

      public void basicNack(Channel channel, long deliveryTag)
      Specified by:
      basicNack in interface MetricsCollector
    • basicNack

      public void basicNack(Channel channel, long deliveryTag, boolean requeue)
      Specified by:
      basicNack in interface MetricsCollector
    • basicReject

      public void basicReject(Channel channel, long deliveryTag)
      Specified by:
      basicReject in interface MetricsCollector
    • basicReject

      public void basicReject(Channel channel, long deliveryTag, boolean requeue)
      Specified by:
      basicReject in interface MetricsCollector
    • cleanStaleState

      public void cleanStaleState()
      Clean inner state for close connections and channels. Inner state is automatically cleaned on connection and channel closing. Thus, this method is provided as a safety net, to be externally called periodically if closing of resources wouldn't work properly for some corner cases.
    • incrementConnectionCount

      protected abstract void incrementConnectionCount(Connection connection)
      Increments connection count. The connection object is passed in as complementary information and without any guarantee of not being null.
      Parameters:
      connection - the connection that has been created (can be null)
    • decrementConnectionCount

      protected abstract void decrementConnectionCount(Connection connection)
      Decrements connection count. The connection object is passed in as complementary information and without any guarantee of not being null.
      Parameters:
      connection - the connection that has been closed (can be null)
    • incrementChannelCount

      protected abstract void incrementChannelCount(Channel channel)
      Increments channel count. The channel object is passed in as complementary information and without any guarantee of not being null.
      Parameters:
      channel - the channel that has been created (can be null)
    • decrementChannelCount

      protected abstract void decrementChannelCount(Channel channel)
      Decrements channel count. The channel object is passed in as complementary information and without any guarantee of not being null.
      Parameters:
      channel -
    • markPublishedMessage

      protected abstract void markPublishedMessage()
      Marks the event of a published message.
    • markMessagePublishFailed

      protected abstract void markMessagePublishFailed()
      Marks the event of a message publishing failure.
    • markConsumedMessage

      protected abstract void markConsumedMessage()
      Marks the event of a consumed message.
    • markAcknowledgedMessage

      protected abstract void markAcknowledgedMessage()
      Marks the event of an acknowledged message.
    • markRejectedMessage

      protected abstract void markRejectedMessage()
      Deprecated.
      Marks the event of a rejected message.
    • markRejectedMessage

      protected void markRejectedMessage(boolean requeue)
      Marks the event of a rejected message.
    • markMessagePublishAcknowledged

      protected abstract void markMessagePublishAcknowledged()
      Marks the event of a message publishing acknowledgement.
    • markMessagePublishNotAcknowledged

      protected abstract void markMessagePublishNotAcknowledged()
      Marks the event of a message publishing not being acknowledged.
    • markPublishedMessageUnrouted

      protected abstract void markPublishedMessageUnrouted()
      Marks the event of a published message not being routed.