Class FilteringMessageListenerAdapter<K,V>

Type Parameters:
K - the key type.
V - the value type.
All Implemented Interfaces:
AcknowledgingConsumerAwareMessageListener<K,V>, AsyncRepliesAware, 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.
  • 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

    • setObservationRegistry

      public void setObservationRegistry(io.micrometer.observation.ObservationRegistry observationRegistry)
      Set the ObservationRegistry to stop observations for filtered records.
      Parameters:
      observationRegistry - the observation registry.
      Since:
      4.0.4
    • 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: GenericMessageListener
      Invoked with data from kafka and provides access to the Consumer. The default implementation throws UnsupportedOperationException.
      Specified by:
      onMessage in interface AcknowledgingConsumerAwareMessageListener<K,V>
      Specified by:
      onMessage in interface GenericMessageListener<K>
      Parameters:
      consumerRecord - the data to be processed.
      acknowledgment - the acknowledgment.
      consumer - the consumer.
    • onMessage

      public void onMessage(org.apache.kafka.clients.consumer.ConsumerRecord<K,V> data)
      Description copied from interface: AcknowledgingConsumerAwareMessageListener
      Invoked with data from kafka. Containers should never call this since it they will detect that we are a consumer aware acknowledging listener.
      Specified by:
      onMessage in interface AcknowledgingConsumerAwareMessageListener<K,V>
      Specified by:
      onMessage in interface GenericMessageListener<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: GenericMessageListener
      Invoked with data from kafka. The default implementation throws UnsupportedOperationException.
      Specified by:
      onMessage in interface GenericMessageListener<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: GenericMessageListener
      Invoked with data from kafka and provides access to the Consumer. The default implementation throws UnsupportedOperationException.
      Specified by:
      onMessage in interface GenericMessageListener<K>
      Parameters:
      data - the data to be processed.
      consumer - the consumer.