Class LoggingErrorHandler

java.lang.Object
io.fluxzero.sdk.tracking.LoggingErrorHandler
All Implemented Interfaces:
ErrorHandler

public class LoggingErrorHandler extends Object implements ErrorHandler
The default ErrorHandler implementation used by Fluxzero consumers.

This handler logs errors that occur during message tracking and processing, then allows tracking to continue. It is the recommended starting point for consumer configuration. The failed operation is not retried: a normally completed batch can advance its position past the failure. Monitor these failures and arrange reconciliation or replay when needed. Choose ForeverRetryingErrorHandler only for effects whose recoverable failures must hold up progress; choose ThrowingErrorHandler only when an operator-controlled stop and explicit restart are intended.

Logging Behavior:

  • Technical exceptions (i.e., not FunctionalException) are always logged at ERROR level.
  • FunctionalExceptions are logged at WARN level if logFunctionalErrors is true.
  • The error message and full exception are included in logs to aid observability.

Control Flow:

  • Tracking always continues; no exception is thrown.
  • The original error is returned, and may be published as a Result message.
  • The retryFunction is not executed in this implementation.

Usage: This handler is used by default if no custom errorHandler is specified in the Consumer annotation or ConsumerConfiguration.

@Consumer(name = "default")
public class MyHandler {
    @HandleEvent
    void on(UserRegistered event) {
        // Failures are logged; processing continues without retry
    }
}
See Also:
  • Constructor Details

    • LoggingErrorHandler

      public LoggingErrorHandler()
      Constructs a LoggingErrorHandler that logs both technical and functional errors.
  • Method Details

    • handleError

      public Object handleError(Throwable error, String errorMessage, Callable<?> retryFunction)
      Logs the given error and allows tracking to continue.
      Specified by:
      handleError in interface ErrorHandler
      Parameters:
      error - the Throwable encountered during message processing
      errorMessage - context about the failure
      retryFunction - the operation that was attempted (ignored in this implementation)
      Returns:
      the original error object (may be published as a Result message)