org.axonframework.saga.annotation
Class RetryingErrorHandler

java.lang.Object
  extended by org.axonframework.saga.annotation.RetryingErrorHandler
All Implemented Interfaces:
ErrorHandler

public class RetryingErrorHandler
extends Object
implements ErrorHandler

ErrorHandler implementation that retries Events on non-transient exceptions.

Since:
2.4.2
Author:
Allard Buijze

Nested Class Summary
static class RetryingErrorHandler.TimeoutConfiguration
          Definition of a timeout to use for a specific range of retries
 
Constructor Summary
RetryingErrorHandler()
          Initialize an instance of the RetryingErrorHandler that indefinitely retries each 2 seconds.
RetryingErrorHandler(RetryingErrorHandler.TimeoutConfiguration... timeoutConfigurations)
          Initialize an instance of the RetryingErrorHandler that uses the given TimeoutConfigurations that describe which retry timeout should be used for each number of retries.
 
Method Summary
protected  boolean isTransient(Throwable exception)
          Indicates whether the given exception is transient (i.e.
 RetryPolicy onErrorInvoking(Saga saga, EventMessage publishedEvent, int invocationCount, Exception e)
          Invoked when an error occurs when a Saga instance is invoked.
 RetryPolicy onErrorPreparing(Class<? extends Saga> sagaType, EventMessage<?> publishedEvent, int invocationCount, Exception e)
          Invoked when an error occurs preparing Sagas.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RetryingErrorHandler

public RetryingErrorHandler()
Initialize an instance of the RetryingErrorHandler that indefinitely retries each 2 seconds.


RetryingErrorHandler

public RetryingErrorHandler(RetryingErrorHandler.TimeoutConfiguration... timeoutConfigurations)
Initialize an instance of the RetryingErrorHandler that uses the given TimeoutConfigurations that describe which retry timeout should be used for each number of retries.

Parameters:
timeoutConfigurations - The definitions of the timeouts to apply to each retry
Method Detail

onErrorPreparing

public RetryPolicy onErrorPreparing(Class<? extends Saga> sagaType,
                                    EventMessage<?> publishedEvent,
                                    int invocationCount,
                                    Exception e)
Description copied from interface: ErrorHandler
Invoked when an error occurs preparing Sagas. This is the phase where sagas are looked up using their associations.

Specified by:
onErrorPreparing in interface ErrorHandler
Parameters:
sagaType - The type of Saga to prepare
publishedEvent - The event being published
invocationCount - The number of attempts to prepare (is always at least 1)
e - The exception that occurred in this attempt
Returns:
the expected behavior for the event handling component

onErrorInvoking

public RetryPolicy onErrorInvoking(Saga saga,
                                   EventMessage publishedEvent,
                                   int invocationCount,
                                   Exception e)
Description copied from interface: ErrorHandler
Invoked when an error occurs when a Saga instance is invoked. These are errors thrown by the Saga itself.

Specified by:
onErrorInvoking in interface ErrorHandler
Parameters:
saga - The Saga instance being invoked
publishedEvent - The event handled by the Saga
invocationCount - The number of times this event has been offered to the Saga, including the last, failed, attempt
e - The exception that occurred in the last attempt to invoke the Saga
Returns:
The Policy describing what the SagaManager should do with this exception (retry, skip, etc)

isTransient

protected boolean isTransient(Throwable exception)
Indicates whether the given exception is transient (i.e. could produce a different result when retried). Exceptions that are non-transient will not be eligible for a retry.

This implementation will check if the exception or one of its causes is an instance of AxonNonTransientException.

Parameters:
exception - The exception to inspect
Returns:
true if the exception is transient, otherwise false.


Copyright © 2010-2016. All Rights Reserved.