Class ThrowingErrorHandler
- All Implemented Interfaces:
ErrorHandler
ErrorHandler implementation that forcefully halts message tracking by throwing any encountered errors.
Warning: this handler does not retry or automatically resume. It logs the error (if configured)
and rethrows the original Throwable, which can stop the affected tracker until explicit restart, typically
application restart or redeployment after repair. This includes FunctionalException: an ordinary business
rejection can stop further processing by that tracker. Other trackers or application instances may continue.
Start with the default LoggingErrorHandler. Use this policy only for a deliberate operator-controlled
stop, with alerts and a repair/restart procedure. When recoverable failures should be retried automatically and all
repeated effects are safe, consider RetryingErrorHandler or ForeverRetryingErrorHandler instead.
Stopping does not roll back effects already completed; recovery may deliver the failed work again.
Logging Behavior:
- Technical exceptions (i.e., not
FunctionalException) are logged iflogTechnicalErrorsistrue. FunctionalExceptions are logged iflogFunctionalErrorsistrue.- In either case, the log level is
ERRORand includes the full stack trace.
Usage: Can be registered via Consumer.errorHandler() or programmatically via ConsumerConfiguration.
@Consumer(name = "operator-controlled-projection", errorHandler = ThrowingErrorHandler.class)
public class OperatorControlledProjection {
@HandleEvent
void on(ProjectionUpdated event) {
// On failure: alert, repair, then explicitly restart tracking
}
}
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionConstructs a default ThrowingErrorHandler that logs both functional and technical errors. -
Method Summary
Modifier and TypeMethodDescriptionhandleError(Throwable error, String errorMessage, Callable<?> retryFunction) Handles the given error by optionally logging it and then throwing it to halt message tracking.protected voidLogs the given error based on its type and logging configuration.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface ErrorHandler
handleError
-
Constructor Details
-
ThrowingErrorHandler
public ThrowingErrorHandler()Constructs a default ThrowingErrorHandler that logs both functional and technical errors.
-
-
Method Details
-
handleError
Handles the given error by optionally logging it and then throwing it to halt message tracking.- Specified by:
handleErrorin interfaceErrorHandler- Parameters:
error- theThrowableencountered during message processingerrorMessage- context about the failureretryFunction- the operation that was attempted (ignored in this implementation)- Returns:
- never returns normally – always throws the original error
-
logError
-