Class CompositeBatchInterceptor<K,V>
- java.lang.Object
-
- org.springframework.kafka.listener.CompositeBatchInterceptor<K,V>
-
- Type Parameters:
K- the key type.V- the value type.
- All Implemented Interfaces:
BatchInterceptor<K,V>,ThreadStateProcessor
public class CompositeBatchInterceptor<K,V> extends java.lang.Object implements BatchInterceptor<K,V>
ABatchInterceptorthat delegates to one or moreBatchInterceptors in order.- Since:
- 2.7
-
-
Constructor Summary
Constructors Constructor Description CompositeBatchInterceptor(BatchInterceptor<K,V>... delegates)Construct an instance with the provided delegates.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclearThreadState(org.apache.kafka.clients.consumer.Consumer<?,?> consumer)Call to clear thread-bound resources which were set up inThreadStateProcessor.setupThreadState(Consumer).voidfailure(org.apache.kafka.clients.consumer.ConsumerRecords<K,V> records, java.lang.Exception exception, org.apache.kafka.clients.consumer.Consumer<K,V> consumer)Called after the listener throws an exception.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.voidsetupThreadState(org.apache.kafka.clients.consumer.Consumer<?,?> consumer)Call to set up thread-bound resources which will be available for the entire duration of enclosed operation involving aConsumer.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.
-
-
-
Constructor Detail
-
CompositeBatchInterceptor
@SafeVarargs public CompositeBatchInterceptor(BatchInterceptor<K,V>... delegates)
Construct an instance with the provided delegates.- Parameters:
delegates- the delegates.
-
-
Method Detail
-
intercept
public 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)
Description copied from interface:BatchInterceptorPerform some action on the records or return a different one. If null is returned the records will be skipped. Invoked before the listener.- Specified by:
interceptin interfaceBatchInterceptor<K,V>- Parameters:
records- the records.consumer- the consumer.- Returns:
- the records or null.
-
success
public void success(org.apache.kafka.clients.consumer.ConsumerRecords<K,V> records, org.apache.kafka.clients.consumer.Consumer<K,V> consumer)
Description copied from interface:BatchInterceptorCalled after the listener exits normally.- Specified by:
successin interfaceBatchInterceptor<K,V>- Parameters:
records- the records.consumer- the consumer.
-
failure
public void failure(org.apache.kafka.clients.consumer.ConsumerRecords<K,V> records, java.lang.Exception exception, org.apache.kafka.clients.consumer.Consumer<K,V> consumer)
Description copied from interface:BatchInterceptorCalled after the listener throws an exception.- Specified by:
failurein interfaceBatchInterceptor<K,V>- Parameters:
records- the records.exception- the exception.consumer- the consumer.
-
setupThreadState
public void setupThreadState(org.apache.kafka.clients.consumer.Consumer<?,?> consumer)
Description copied from interface:ThreadStateProcessorCall to set up thread-bound resources which will be available for the entire duration of enclosed operation involving aConsumer.- Specified by:
setupThreadStatein interfaceThreadStateProcessor- Parameters:
consumer- the consumer.
-
clearThreadState
public void clearThreadState(org.apache.kafka.clients.consumer.Consumer<?,?> consumer)
Description copied from interface:ThreadStateProcessorCall to clear thread-bound resources which were set up inThreadStateProcessor.setupThreadState(Consumer).- Specified by:
clearThreadStatein interfaceThreadStateProcessor- Parameters:
consumer- the consumer.
-
-