Class ForeverRetryingErrorHandler
java.lang.Object
io.fluxzero.sdk.tracking.RetryingErrorHandler
io.fluxzero.sdk.tracking.ForeverRetryingErrorHandler
- All Implemented Interfaces:
ErrorHandler
A specialized
RetryingErrorHandler that retries failed operations indefinitely until they succeed.
This handler is useful in scenarios where failure is considered temporary and must eventually resolve before processing can proceed. It ensures **no message is ever skipped or dropped**, regardless of how many attempts are required.
Behavior:
- Applies retry logic to all errors that match the provided
errorFilter(default: non-functional errors). - Uses capped exponential backoff by default, starting at 10 seconds and capped at 1 minute.
- Never stops the consumer or throws — tracking continues until the retry succeeds.
- Logs retry attempts and outcomes via inherited
RetryConfiguration.
Use Cases:
- Systems that rely on eventual consistency and cannot tolerate message loss
- Recoverable infrastructure failures (e.g., DB outages, network timeouts)
- Replaying old messages into strict projections
Usage Example:
@Consumer(name = "criticalProjection", errorHandler = ForeverRetryingErrorHandler.class)
public class StrictProjectionHandler {
@HandleEvent
void on(FinancialTransaction event) {
// Will retry forever on failure until the event is handled successfully
}
}
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionConstructs aForeverRetryingErrorHandlerwith capped exponential backoff, starting at 10 seconds and capped at 1 minute, retrying non-functional errors and logging both functional and technical failures.ForeverRetryingErrorHandler(RetryConfiguration retryConfiguration) Constructs aForeverRetryingErrorHandlerwith a custom retry configuration, retrying non-functional errors and logging both functional and technical failures.ForeverRetryingErrorHandler(RetryConfiguration retryConfiguration, Predicate<Throwable> errorFilter, boolean logFunctionalErrors) Constructs aForeverRetryingErrorHandlerwith a custom retry configuration.ForeverRetryingErrorHandler(Duration delay, Predicate<Throwable> errorFilter, boolean logFunctionalErrors, Function<Throwable, ?> errorMapper) Constructs aForeverRetryingErrorHandlerwith custom delay, error filtering, logging, and error mapping. -
Method Summary
Methods inherited from class RetryingErrorHandler
handleError, isTechnicalError, logErrorMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface ErrorHandler
handleError
-
Constructor Details
-
ForeverRetryingErrorHandler
public ForeverRetryingErrorHandler()Constructs aForeverRetryingErrorHandlerwith capped exponential backoff, starting at 10 seconds and capped at 1 minute, retrying non-functional errors and logging both functional and technical failures. -
ForeverRetryingErrorHandler
public ForeverRetryingErrorHandler(Duration delay, Predicate<Throwable> errorFilter, boolean logFunctionalErrors, Function<Throwable, ?> errorMapper) Constructs aForeverRetryingErrorHandlerwith custom delay, error filtering, logging, and error mapping.- Parameters:
delay- the delay between retrieserrorFilter- predicate to select which errors should trigger retrieslogFunctionalErrors- whether to log functional errorserrorMapper- maps the final error into a result (though retries never exhaust)
-
ForeverRetryingErrorHandler
Constructs aForeverRetryingErrorHandlerwith a custom retry configuration, retrying non-functional errors and logging both functional and technical failures.- Parameters:
retryConfiguration- retry delay strategy, logging callbacks, and error mapping
-
ForeverRetryingErrorHandler
public ForeverRetryingErrorHandler(RetryConfiguration retryConfiguration, Predicate<Throwable> errorFilter, boolean logFunctionalErrors) Constructs aForeverRetryingErrorHandlerwith a custom retry configuration. The configured maximum number of retries is ignored and changed to unlimited to preserve the contract of this handler.- Parameters:
retryConfiguration- retry delay strategy, logging callbacks, and error mappingerrorFilter- predicate to select which errors should trigger retrieslogFunctionalErrors- whether to log functional errors
-