Class RecordingMessageMonitor

java.lang.Object
org.axonframework.test.util.RecordingMessageMonitor
All Implemented Interfaces:
MessageMonitor<Message>

public class RecordingMessageMonitor extends Object implements MessageMonitor<Message>
A message monitor implementation that records the processing results of messages in the provided MessageMonitorReport instances. It supports logging the processing outcomes if logging is enabled. This monitor tracks whether messages were successfully processed, failed, or ignored and stores this information in the provided reports.

The class provides two constructors: one allows configuring a single report instance while enabling logging, and the other accepts a list of reports, defaulting logging to disabled.

The monitor provides functionality to handle messages as they are ingested and uses a callback to record the processing result for each message.

For further inspection, for example logging, you can overwrite the onReportSuccess(Message), onReportFailure(Message, Throwable) and onReportIgnored(Message) methods.

  • Field Details

  • Constructor Details

  • Method Details

    • onMessageIngested

      public final MessageMonitor.MonitorCallback onMessageIngested(@NotNull @NotNull 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<Message>
      Parameters:
      message - the message to monitor
      Returns:
      the callback
    • report

      public MessageMonitorReport report()
      Returns:
      Returns the report that stores the results of messages processed by this monitor.
    • onReportSuccess

      protected void onReportSuccess(@Nonnull Message message)
      Hook for subclasses to perform additional actions when a message is reported as successful.
      Parameters:
      message - The message that was reported as successful.
    • onReportFailure

      protected void onReportFailure(@Nonnull Message message, @Nonnull Throwable cause)
      Hook for subclasses to perform additional actions when a message is reported as failed.
      Parameters:
      message - The message that was reported as failed.
      cause - The cause of the failure.
    • onReportIgnored

      protected void onReportIgnored(@Nonnull Message message)
      Hook for subclasses to perform additional actions when a message is reported as ignored.
      Parameters:
      message - The message that was reported as ignored.