Interface RecordFilterStrategy<K,V>
- Type Parameters:
K
- the key type.V
- the value type.
public interface RecordFilterStrategy<K,V>
Implementations of this interface can signal that a record about
to be delivered to a message listener should be discarded instead
of being delivered.
- Author:
- Gary Russell, Sanghyeok An
-
Method Summary
Modifier and TypeMethodDescriptionboolean
Return true if the record should be discarded.filterBatch
(List<org.apache.kafka.clients.consumer.ConsumerRecord<K, V>> records) Filter an entire batch of records; to filter all records, return an empty list, not null.default boolean
Determine whetherFilteringBatchMessageListenerAdapter
should invoke theBatchMessageListener
when allConsumerRecord
s in a batch have been filtered out resulting in empty list.
-
Method Details
-
filter
Return true if the record should be discarded.- Parameters:
consumerRecord
- the record.- Returns:
- true to discard.
-
filterBatch
default List<org.apache.kafka.clients.consumer.ConsumerRecord<K,V>> filterBatch(List<org.apache.kafka.clients.consumer.ConsumerRecord<K, V>> records) Filter an entire batch of records; to filter all records, return an empty list, not null.- Parameters:
records
- the records.- Returns:
- the filtered records.
- Since:
- 2.8
-
ignoreEmptyBatch
default boolean ignoreEmptyBatch()Determine whetherFilteringBatchMessageListenerAdapter
should invoke theBatchMessageListener
when allConsumerRecord
s in a batch have been filtered out resulting in empty list. By default, do invoke theBatchMessageListener
(return false).- Returns:
- true for
FilteringBatchMessageListenerAdapter
to not invokeBatchMessageListener
when allConsumerRecord
in a batch filtered out - Since:
- 3.3
-