Package org.axonframework.eventhandling
Class LoggingErrorHandler
java.lang.Object
org.axonframework.eventhandling.LoggingErrorHandler
- All Implemented Interfaces:
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 Summary
ConstructorsConstructorDescriptionInitialize the LoggingErrorHandler using the logger for "org.axonframework.eventhandling.LoggingErrorHandler".LoggingErrorHandler(org.slf4j.Logger logger) Initialize the LoggingErrorHandler to use the givenloggerto log errors -
Method Summary
Modifier and TypeMethodDescriptionvoidonError(Exception exception, EventMessage<?> event, EventMessageHandler eventHandler) Invoked after giveneventListenerfailed to handle givenevent.
-
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 givenloggerto 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:ListenerInvocationErrorHandlerInvoked after giveneventListenerfailed to handle givenevent. 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:
onErrorin interfaceListenerInvocationErrorHandler- Parameters:
exception- The exception thrown by the given eventListenerevent- The event that triggered the exceptioneventHandler- The listener that failed to handle given event
-