Class FilteringMessageListenerAdapter<K,V>
java.lang.Object
org.springframework.kafka.listener.adapter.AbstractDelegatingMessageListenerAdapter<MessageListener<K,V>>
org.springframework.kafka.listener.adapter.AbstractFilteringMessageListener<K, V, MessageListener<K,V>>
org.springframework.kafka.listener.adapter.FilteringMessageListenerAdapter<K,V>
- Type Parameters:
K- the key type.V- the value type.
- All Implemented Interfaces:
AcknowledgingConsumerAwareMessageListener<K,V>, ConsumerSeekAware, DelegatingMessageListener<MessageListener<K, V>>, GenericMessageListener<org.apache.kafka.clients.consumer.ConsumerRecord<K, V>>, MessageListener<K, V>
public class FilteringMessageListenerAdapter<K,V>
extends AbstractFilteringMessageListener<K, V, MessageListener<K,V>>
implements AcknowledgingConsumerAwareMessageListener<K,V>
A
MessageListener adapter that implements filter logic
via a RecordFilterStrategy.-
Nested Class Summary
Nested classes/interfaces inherited from interface ConsumerSeekAware
ConsumerSeekAware.ConsumerSeekCallback -
Field Summary
Fields inherited from class AbstractDelegatingMessageListenerAdapter
delegate, delegateType, logger -
Constructor Summary
ConstructorsConstructorDescriptionFilteringMessageListenerAdapter(MessageListener<K, V> delegate, RecordFilterStrategy<K, V> recordFilterStrategy) Create an instance with the supplied strategy and delegate listener.FilteringMessageListenerAdapter(MessageListener<K, V> delegate, RecordFilterStrategy<K, V> recordFilterStrategy, boolean ackDiscarded) Create an instance with the supplied strategy and delegate listener. -
Method Summary
Modifier and TypeMethodDescriptionvoidInvoked with data from kafka.voidonMessage(org.apache.kafka.clients.consumer.ConsumerRecord<K, V> data, @Nullable org.apache.kafka.clients.consumer.Consumer<?, ?> consumer) Invoked with data from kafka and provides access to theConsumer.voidonMessage(org.apache.kafka.clients.consumer.ConsumerRecord<K, V> data, @Nullable Acknowledgment acknowledgment) Invoked with data from kafka.voidonMessage(org.apache.kafka.clients.consumer.ConsumerRecord<K, V> consumerRecord, @Nullable Acknowledgment acknowledgment, @Nullable org.apache.kafka.clients.consumer.Consumer<?, ?> consumer) Invoked with data from kafka and provides access to theConsumer.Methods inherited from class AbstractFilteringMessageListener
filter, getRecordFilterStrategyMethods inherited from class AbstractDelegatingMessageListenerAdapter
getDelegate, onIdleContainer, onPartitionsAssigned, onPartitionsRevoked, registerSeekCallbackMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface ConsumerSeekAware
onFirstPoll, unregisterSeekCallback
-
Constructor Details
-
FilteringMessageListenerAdapter
public FilteringMessageListenerAdapter(MessageListener<K, V> delegate, RecordFilterStrategy<K, V> recordFilterStrategy) Create an instance with the supplied strategy and delegate listener.- Parameters:
delegate- the delegate.recordFilterStrategy- the filter.
-
FilteringMessageListenerAdapter
public FilteringMessageListenerAdapter(MessageListener<K, V> delegate, RecordFilterStrategy<K, V> recordFilterStrategy, boolean ackDiscarded) Create an instance with the supplied strategy and delegate listener.- Parameters:
delegate- the delegate.recordFilterStrategy- the filter.ackDiscarded- true to ack (commit offset for) discarded messages when the listener is configured for manual acks.
-
-
Method Details
-
onMessage
public void onMessage(org.apache.kafka.clients.consumer.ConsumerRecord<K, V> consumerRecord, @Nullable Acknowledgment acknowledgment, @Nullable org.apache.kafka.clients.consumer.Consumer<?, ?> consumer) Description copied from interface:GenericMessageListenerInvoked with data from kafka and provides access to theConsumer. The default implementation throwsUnsupportedOperationException.- Specified by:
onMessagein interfaceAcknowledgingConsumerAwareMessageListener<K,V> - Specified by:
onMessagein interfaceGenericMessageListener<K>- Parameters:
consumerRecord- the data to be processed.acknowledgment- the acknowledgment.consumer- the consumer.
-
onMessage
Description copied from interface:AcknowledgingConsumerAwareMessageListenerInvoked with data from kafka. Containers should never call this since it they will detect that we are a consumer aware acknowledging listener.- Specified by:
onMessagein interfaceAcknowledgingConsumerAwareMessageListener<K,V> - Specified by:
onMessagein interfaceGenericMessageListener<K>- Parameters:
data- the data to be processed.
-
onMessage
public void onMessage(org.apache.kafka.clients.consumer.ConsumerRecord<K, V> data, @Nullable Acknowledgment acknowledgment) Description copied from interface:GenericMessageListenerInvoked with data from kafka. The default implementation throwsUnsupportedOperationException.- Specified by:
onMessagein interfaceGenericMessageListener<K>- Parameters:
data- the data to be processed.acknowledgment- the acknowledgment.
-
onMessage
public void onMessage(org.apache.kafka.clients.consumer.ConsumerRecord<K, V> data, @Nullable org.apache.kafka.clients.consumer.Consumer<?, ?> consumer) Description copied from interface:GenericMessageListenerInvoked with data from kafka and provides access to theConsumer. The default implementation throwsUnsupportedOperationException.- Specified by:
onMessagein interfaceGenericMessageListener<K>- Parameters:
data- the data to be processed.consumer- the consumer.
-