Class RetryEventDeliveryExceptionHandler
- java.lang.Object
-
- io.eventuate.javaclient.eventhandling.exceptionhandling.RetryEventDeliveryExceptionHandler
-
- All Implemented Interfaces:
EventDeliveryExceptionHandler
public class RetryEventDeliveryExceptionHandler extends java.lang.Object implements EventDeliveryExceptionHandler
An exception handler that repeatedly retries
-
-
Constructor Summary
Constructors Constructor Description RetryEventDeliveryExceptionHandler(EventuateClientScheduler eventuateClientScheduler)Creates a RetryEventDeliveryExceptionHandler that uses the specified scheduler
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidhandle(EventDeliveryExceptionHandlerState state, java.lang.Throwable t, java.lang.Runnable retry, java.util.function.Consumer<java.lang.Throwable> fail, java.lang.Runnable ignore)Retry after the timeout unless the max retries has been exceeded or the supplied throwable is not handledbooleanhandles(java.lang.Throwable t)Returns true if this handles the throwableEventDeliveryExceptionHandlerStatemakeState(java.lang.Throwable t)create the state used for handling an exceptionRetryEventDeliveryExceptionHandlerwithExceptions(java.lang.Class<? extends java.lang.Throwable>... throwables)Specifies the exceptions that this exception handler can handleRetryEventDeliveryExceptionHandlerwithInfiniteRetries()Specifies an infinite number of retriesRetryEventDeliveryExceptionHandlerwithMaxRetries(int numberOfRetries)Specifies the maximum number of retriesRetryEventDeliveryExceptionHandlerwithRetryInterval(java.time.Duration retryInterval)Specifies the interval between retries
-
-
-
Constructor Detail
-
RetryEventDeliveryExceptionHandler
public RetryEventDeliveryExceptionHandler(EventuateClientScheduler eventuateClientScheduler)
Creates a RetryEventDeliveryExceptionHandler that uses the specified scheduler- Parameters:
eventuateClientScheduler- the scheduler
-
-
Method Detail
-
handles
public boolean handles(java.lang.Throwable t)
Description copied from interface:EventDeliveryExceptionHandlerReturns true if this handles the throwable- Specified by:
handlesin interfaceEventDeliveryExceptionHandler- Parameters:
t- the throwable- Returns:
- true if handled, false otherwise
-
makeState
public EventDeliveryExceptionHandlerState makeState(java.lang.Throwable t)
Description copied from interface:EventDeliveryExceptionHandlercreate the state used for handling an exception- Specified by:
makeStatein interfaceEventDeliveryExceptionHandler- Parameters:
t- the throwable- Returns:
- the state used by the handler
-
handle
public void handle(EventDeliveryExceptionHandlerState state, java.lang.Throwable t, java.lang.Runnable retry, java.util.function.Consumer<java.lang.Throwable> fail, java.lang.Runnable ignore)
Retry after the timeout unless the max retries has been exceeded or the supplied throwable is not handled- Specified by:
handlein interfaceEventDeliveryExceptionHandler- Parameters:
state- the statet- the throwableretry- invoked asynchronously to retryfail- invoked asynchronously to failignore-
-
withExceptions
@SafeVarargs public final RetryEventDeliveryExceptionHandler withExceptions(java.lang.Class<? extends java.lang.Throwable>... throwables)
Specifies the exceptions that this exception handler can handle- Parameters:
throwables- the exceptions- Returns:
- this
-
withMaxRetries
public RetryEventDeliveryExceptionHandler withMaxRetries(int numberOfRetries)
Specifies the maximum number of retries- Parameters:
numberOfRetries- number of retries to attempt- Returns:
- this
-
withInfiniteRetries
public RetryEventDeliveryExceptionHandler withInfiniteRetries()
Specifies an infinite number of retries- Returns:
- this
-
withRetryInterval
public RetryEventDeliveryExceptionHandler withRetryInterval(java.time.Duration retryInterval)
Specifies the interval between retries- Parameters:
retryInterval- the retry interval- Returns:
- this
-
-