Interface GenericErrorHandler<T>
-
- Type Parameters:
T- the data type.
- All Known Subinterfaces:
BatchErrorHandler,ConsumerAwareBatchErrorHandler,ConsumerAwareErrorHandler,ContainerAwareBatchErrorHandler,ContainerAwareErrorHandler,ErrorHandler,ListenerInvokingBatchErrorHandler,RemainingRecordsErrorHandler
- All Known Implementing Classes:
BatchLoggingErrorHandler,ContainerStoppingBatchErrorHandler,ContainerStoppingErrorHandler,LoggingErrorHandler,RecoveringBatchErrorHandler,RetryingBatchErrorHandler,SeekToCurrentBatchErrorHandler,SeekToCurrentErrorHandler
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
@FunctionalInterface public interface GenericErrorHandler<T>A generic error handler.- Since:
- 1.1
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default voidclearThreadState()Optional method to clear thread state; will be called just before a consumer thread terminates.voidhandle(java.lang.Exception thrownException, T data)Handle the exception.default voidhandle(java.lang.Exception thrownException, T data, org.apache.kafka.clients.consumer.Consumer<?,?> consumer)Handle the exception.default booleanisAckAfterHandle()Return true if the offset should be committed for a handled error (no exception thrown).default voidsetAckAfterHandle(boolean ack)Set to false to prevent the container from committing the offset of a recovered record (when the error handler does not itself throw an exception).
-
-
-
Method Detail
-
handle
void handle(java.lang.Exception thrownException, @Nullable T data)Handle the exception.- Parameters:
thrownException- The exception.data- the data.
-
handle
default void handle(java.lang.Exception thrownException, T data, org.apache.kafka.clients.consumer.Consumer<?,?> consumer)Handle the exception.- Parameters:
thrownException- The exception.data- the data.consumer- the consumer.
-
clearThreadState
default void clearThreadState()
Optional method to clear thread state; will be called just before a consumer thread terminates.- Since:
- 2.3
-
isAckAfterHandle
default boolean isAckAfterHandle()
Return true if the offset should be committed for a handled error (no exception thrown).- Returns:
- true to commit.
- Since:
- 2.3.2
-
setAckAfterHandle
default void setAckAfterHandle(boolean ack)
Set to false to prevent the container from committing the offset of a recovered record (when the error handler does not itself throw an exception).- Parameters:
ack- false to not commit.- Since:
- 2.5.6
-
-