Class PayloadTypeMessageMonitorWrapper<T extends MessageMonitor<Message> & io.dropwizard.metrics5.MetricSet>

java.lang.Object
org.axonframework.extension.metrics.dropwizard.PayloadTypeMessageMonitorWrapper<T>
Type Parameters:
T - The type of the MessageMonitor created for every payload type.Must implement both MessageMonitor and MetricSet
All Implemented Interfaces:
io.dropwizard.metrics5.Metric, io.dropwizard.metrics5.MetricSet, MessageMonitor<Message>

public class PayloadTypeMessageMonitorWrapper<T extends MessageMonitor<Message> & io.dropwizard.metrics5.MetricSet> extends Object implements MessageMonitor<Message>, io.dropwizard.metrics5.MetricSet
A MessageMonitor implementation which creates a new MessageMonitor for every Message payload type ingested by it. The PayloadTypeMessageMonitorWrapper keeps track of all distinct payload types it has created and only creates a new one if there is none present.

The type of MessageMonitor which is created for every payload type is configurable, as long as it implements MessageMonitor and MetricSet.

Since:
3.0
Author:
Steven van Beelen
  • Constructor Details

    • PayloadTypeMessageMonitorWrapper

      public PayloadTypeMessageMonitorWrapper(Supplier<T> monitorSupplier)
      Create a PayloadTypeMessageMonitorWrapper which builds monitors through a given monitorSupplier for every message payload type encountered.
      Parameters:
      monitorSupplier - A Supplier of MessageMonitors of type T for every encountered payload type
    • PayloadTypeMessageMonitorWrapper

      public PayloadTypeMessageMonitorWrapper(Supplier<T> monitorSupplier, Function<Class<?>,String> monitorNameBuilder)
      Create a PayloadTypeMessageMonitorWrapper which builds monitors through a given monitorSupplier for every message payload type encountered and sets the monitor name as specified by the monitorNameBuilder.
      Parameters:
      monitorSupplier - A Supplier of MessageMonitors of type T for every encountered payload type
      monitorNameBuilder - A Function where the payload type is the input (of type Class<?>) and output is the desired name for the monitor (of type String)
  • Method Details

    • onMessageIngested

      public MessageMonitor.MonitorCallback onMessageIngested(Message message)
      Description copied from interface: MessageMonitor
      Takes a message and returns a callback that should be used to inform the message monitor about the result of processing the message
      Specified by:
      onMessageIngested in interface MessageMonitor<T extends MessageMonitor<Message> & io.dropwizard.metrics5.MetricSet>
      Parameters:
      message - the message to monitor
      Returns:
      the callback
    • getMetrics

      public Map<io.dropwizard.metrics5.MetricName,io.dropwizard.metrics5.Metric> getMetrics()
      Specified by:
      getMetrics in interface io.dropwizard.metrics5.MetricSet