org.axonframework.eventhandling.async
Class DefaultErrorHandler

java.lang.Object
  extended by org.axonframework.eventhandling.async.DefaultErrorHandler
All Implemented Interfaces:
ErrorHandler

public class DefaultErrorHandler
extends Object
implements ErrorHandler

An ErrorHandler implementation that returns a fixed RetryPolicy instance when an error occurs.

Since:
2.0
Author:
Allard Buijze

Constructor Summary
DefaultErrorHandler(RetryPolicy retryPolicy)
          Initializes the ErrorHandler, making it return the given retryPolicy when an error occurs.
 
Method Summary
 RetryPolicy handleError(Throwable exception, EventMessage<?> eventMessage, EventListener eventListener)
          Invoked when a handler or the unit of work throws an exception.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultErrorHandler

public DefaultErrorHandler(RetryPolicy retryPolicy)
Initializes the ErrorHandler, making it return the given retryPolicy when an error occurs.

Parameters:
retryPolicy - the policy to return on errors
Method Detail

handleError

public RetryPolicy handleError(Throwable exception,
                               EventMessage<?> eventMessage,
                               EventListener eventListener)
Description copied from interface: ErrorHandler
Invoked when a handler or the unit of work throws an exception. The returned RetryPolicy tells the Event Processor what to do to resolve the issue (commit or rollback Unit of Work, reschedule or skip the Event).

The Error Handler may invoke the given eventListener with the given eventMessage to attempt to resolve the issue. Do note that the returned policy reflects this, to prevent duplicate invocation of the listener.

The Error Handler should not throw exceptions.

Specified by:
handleError in interface ErrorHandler
Parameters:
exception - The exception thrown by the handler (or unit of work)
eventMessage - The message being processed
eventListener - The listener throwing the exception, or null if an error occurred in the Unit of Work
Returns:
the policy the Event Processor should apply to resolve the issue


Copyright © 2010-2016. All Rights Reserved.