Class ForeverRetryingErrorHandler
java.lang.Object
io.fluxcapacitor.javaclient.tracking.RetryingErrorHandler
io.fluxcapacitor.javaclient.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). - Waits a fixed
Duration
between attempts (default: 10 seconds). - 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 aForeverRetryingErrorHandler
with a default 10-second delay between attempts, retrying non-functional errors and logging both functional and technical failures.ForeverRetryingErrorHandler
(Duration delay, Predicate<Throwable> errorFilter, boolean logFunctionalErrors, Function<Throwable, ?> errorMapper) Constructs aForeverRetryingErrorHandler
with custom delay, error filtering, logging, and error mapping. -
Method Summary
Methods inherited from class io.fluxcapacitor.javaclient.tracking.RetryingErrorHandler
handleError, isTechnicalError, logError
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface io.fluxcapacitor.javaclient.tracking.ErrorHandler
handleError
-
Constructor Details
-
ForeverRetryingErrorHandler
public ForeverRetryingErrorHandler()Constructs aForeverRetryingErrorHandler
with a default 10-second delay between attempts, 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 aForeverRetryingErrorHandler
with 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)
-