Interface BatchInterceptor<K,V>
- Type Parameters:
K- the key type.V- the value type.
- All Superinterfaces:
ThreadStateProcessor
- All Known Implementing Classes:
CompositeBatchInterceptor
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
An interceptor for batches of records.
- Since:
- 2.7
- Author:
- Gary Russell
-
Method Summary
Modifier and TypeMethodDescriptiondefault voidfailure(org.apache.kafka.clients.consumer.ConsumerRecords<K, V> records, Exception exception, org.apache.kafka.clients.consumer.Consumer<K, V> consumer) Called after the listener throws an exception.intercept(org.apache.kafka.clients.consumer.ConsumerRecords<K, V> records, org.apache.kafka.clients.consumer.Consumer<K, V> consumer) Perform some action on the records or return a different one.default voidsuccess(org.apache.kafka.clients.consumer.ConsumerRecords<K, V> records, org.apache.kafka.clients.consumer.Consumer<K, V> consumer) Called after the listener exits normally.Methods inherited from interface org.springframework.kafka.listener.ThreadStateProcessor
clearThreadState, setupThreadState
-
Method Details
-
intercept
@Nullable org.apache.kafka.clients.consumer.ConsumerRecords<K,V> intercept(org.apache.kafka.clients.consumer.ConsumerRecords<K, V> records, org.apache.kafka.clients.consumer.Consumer<K, V> consumer) Perform some action on the records or return a different one. If null is returned the records will be skipped. Invoked before the listener.- Parameters:
records- the records.consumer- the consumer.- Returns:
- the records or null.
-
success
default void success(org.apache.kafka.clients.consumer.ConsumerRecords<K, V> records, org.apache.kafka.clients.consumer.Consumer<K, V> consumer) Called after the listener exits normally.- Parameters:
records- the records.consumer- the consumer.
-
failure
default void failure(org.apache.kafka.clients.consumer.ConsumerRecords<K, V> records, Exception exception, org.apache.kafka.clients.consumer.Consumer<K, V> consumer) Called after the listener throws an exception.- Parameters:
records- the records.exception- the exception.consumer- the consumer.
-