Class LoggingErrorHandler

java.lang.Object
org.axonframework.eventhandling.LoggingErrorHandler
All Implemented Interfaces:
ListenerInvocationErrorHandler

public class LoggingErrorHandler extends Object implements ListenerInvocationErrorHandler
Implementation of a ListenerInvocationErrorHandler that logs exceptions as errors but otherwise does nothing to prevent event handling from continuing.
Author:
Rene de Waele
  • Constructor Details

    • LoggingErrorHandler

      public LoggingErrorHandler()
      Initialize the LoggingErrorHandler using the logger for "org.axonframework.eventhandling.LoggingErrorHandler".
    • LoggingErrorHandler

      public LoggingErrorHandler(org.slf4j.Logger logger)
      Initialize the LoggingErrorHandler to use the given logger to log errors
      Parameters:
      logger - the logger to log errors with
  • Method Details

    • onError

      public void onError(@Nonnull Exception exception, @Nonnull EventMessage<?> event, @Nonnull EventMessageHandler eventHandler)
      Description copied from interface: ListenerInvocationErrorHandler
      Invoked after given eventListener failed to handle given event. Implementations have a choice of options for how to continue:

      • To ignore this error no special action is required. Processing will continue for this and subsequent events.
      • To retry processing the event, implementations can re-invoke EventMessageHandler.handle(EventMessage) on the eventListener once or multiple times.
      • To terminate event handling altogether and stop propagating the event to other listeners implementations may throw an exception.
      Specified by:
      onError in interface ListenerInvocationErrorHandler
      Parameters:
      exception - The exception thrown by the given eventListener
      event - The event that triggered the exception
      eventHandler - The listener that failed to handle given event