Interface ErrorHandler
- All Known Implementing Classes:
ForeverRetryingErrorHandler
,LoggingErrorHandler
,RetryingErrorHandler
,SilentErrorHandler
,ThrowingErrorHandler
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
An interface to handle errors encountered during message tracking and processing, with the ability to retry
operations.
Several built-in ErrorHandler
implementations are provided for different operational needs:
Implementation | Retries | Throws | Skips Messages | Logging | Use Case |
---|---|---|---|---|---|
ThrowingErrorHandler |
No | Always | No | Optional (configurable per type) | Critical systems where any failure must stop processing |
LoggingErrorHandler |
No | Never | Yes | Error (technical), Warn (functional) | Default for general-purpose robust message tracking |
SilentErrorHandler |
No | Never | Yes | Optional (configurable level or silent) | Logging/audit projections, passive consumers |
RetryingErrorHandler |
Yes (configurable) | Optional (on final failure) | Optional (configurable) | Error/Warn on failure and retry attempts | Recoverable transient failures with fallback strategy |
ForeverRetryingErrorHandler |
Yes (infinite) | Never | No | Error/Warn on retries | Guaranteed delivery and strict durability requirements |
-
Method Summary
Modifier and TypeMethodDescriptiondefault void
handleError
(Throwable error, String errorMessage, Runnable retryFunction) Handles an error encountered during message processing and provides an option to retry the operation.handleError
(Throwable error, String errorMessage, Callable<?> retryFunction) Handles an error encountered during message processing and provides an option to retry the operation.
-
Method Details
-
handleError
Handles an error encountered during message processing and provides an option to retry the operation.- Parameters:
error
- the Throwable instance representing the error that occurrederrorMessage
- a descriptive message providing context about the errorretryFunction
- a Callable representing the operation to retry in case of failure- Returns:
- an Object which represents the result of the error handling or retry operation. In case an exception is thrown, tracking will be suspended. In case an error is returned but not thrown, tracking will continue, and the error may be logged as a Result message. Any other return value may be logged as a Result message.
-
handleError
Handles an error encountered during message processing and provides an option to retry the operation. Invoked when the return value of the error handler (even if the return value is an exception) is not relevant.- Parameters:
error
- the Throwable instance representing the error that occurrederrorMessage
- a descriptive message providing context about the errorretryFunction
- a Callable representing the operation to retry in case of failure
-