Package org.axonframework.test.util
Class RecordingMessageMonitor
java.lang.Object
org.axonframework.test.util.RecordingMessageMonitor
- All Implemented Interfaces:
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 theonReportSuccess(Message), onReportFailure(Message, Throwable)
and onReportIgnored(Message) methods.-
Nested Class Summary
Nested classes/interfaces inherited from interface org.axonframework.messaging.monitoring.MessageMonitor
MessageMonitor.MonitorCallback -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionConstructs a RecordingMessageMonitor that records message processing outcomes in a newMessageMonitorReport.Constructs a RecordingMessageMonitor that records message processing outcomes in the providedMessageMonitorReportand configures optional logging. -
Method Summary
Modifier and TypeMethodDescriptiononMessageIngested(@NotNull Message message) Takes a message and returns a callback that should be used to inform the message monitor about the result of processing the messageprotected voidonReportFailure(Message message, Throwable cause) Hook for subclasses to perform additional actions when a message is reported as failed.protected voidonReportIgnored(Message message) Hook for subclasses to perform additional actions when a message is reported as ignored.protected voidonReportSuccess(Message message) Hook for subclasses to perform additional actions when a message is reported as successful.report()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.axonframework.messaging.monitoring.MessageMonitor
onMessagesIngested
-
Field Details
-
report
-
-
Constructor Details
-
RecordingMessageMonitor
public RecordingMessageMonitor()Constructs a RecordingMessageMonitor that records message processing outcomes in a newMessageMonitorReport.- See Also:
-
RecordingMessageMonitor
Constructs a RecordingMessageMonitor that records message processing outcomes in the providedMessageMonitorReportand configures optional logging.- Parameters:
report- TheMessageMonitorReportinstance to record message processing results.
-
-
Method Details
-
onMessageIngested
Description copied from interface:MessageMonitorTakes a message and returns a callback that should be used to inform the message monitor about the result of processing the message- Specified by:
onMessageIngestedin interfaceMessageMonitor<Message>- Parameters:
message- the message to monitor- Returns:
- the callback
-
report
- Returns:
- Returns the report that stores the results of messages processed by this monitor.
-
onReportSuccess
Hook for subclasses to perform additional actions when a message is reported as successful.- Parameters:
message- The message that was reported as successful.
-
onReportFailure
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
Hook for subclasses to perform additional actions when a message is reported as ignored.- Parameters:
message- The message that was reported as ignored.
-