Class ForeverRetryingErrorHandler

java.lang.Object
io.fluxcapacitor.javaclient.tracking.RetryingErrorHandler
io.fluxcapacitor.javaclient.tracking.ForeverRetryingErrorHandler
All Implemented Interfaces:
ErrorHandler

public class ForeverRetryingErrorHandler extends RetryingErrorHandler
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 Details

    • ForeverRetryingErrorHandler

      public ForeverRetryingErrorHandler()
      Constructs a ForeverRetryingErrorHandler 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 a ForeverRetryingErrorHandler with custom delay, error filtering, logging, and error mapping.
      Parameters:
      delay - the delay between retries
      errorFilter - predicate to select which errors should trigger retries
      logFunctionalErrors - whether to log functional errors
      errorMapper - maps the final error into a result (though retries never exhaust)