Interface AcknowledgingShareConsumerAwareMessageListener<K,V>

Type Parameters:
K - the key type
V - the value type
All Superinterfaces:
GenericMessageListener<org.apache.kafka.clients.consumer.ConsumerRecord<K,V>>
All Known Implementing Classes:
ShareRecordMessagingMessageListenerAdapter
Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface AcknowledgingShareConsumerAwareMessageListener<K,V> extends GenericMessageListener<org.apache.kafka.clients.consumer.ConsumerRecord<K,V>>
A message listener for share consumer containers with acknowledgment support.

This interface provides access to both the ShareConsumer instance and acknowledgment capabilities. The acknowledgment parameter behavior depends on the container's acknowledgment mode:

  • Explicit mode: The acknowledgment parameter is non-null and must be used to acknowledge each record
  • Implicit mode: The acknowledgment parameter is null and records are automatically acknowledged

This is the primary listener interface for share consumers when you need access to the ShareConsumer instance or need explicit acknowledgment control.

Since:
4.0
See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    default void
    onMessage(org.apache.kafka.clients.consumer.ConsumerRecord<K,V> data)
    Invoked with data from kafka.
    void
    onShareRecord(org.apache.kafka.clients.consumer.ConsumerRecord<K,V> data, @Nullable ShareAcknowledgment acknowledgment, org.apache.kafka.clients.consumer.ShareConsumer<?,?> consumer)
    Invoked with data from kafka, an acknowledgment, and provides access to the consumer.

    Methods inherited from interface GenericMessageListener

    onMessage, onMessage, onMessage
  • Method Details

    • onShareRecord

      void onShareRecord(org.apache.kafka.clients.consumer.ConsumerRecord<K,V> data, @Nullable ShareAcknowledgment acknowledgment, org.apache.kafka.clients.consumer.ShareConsumer<?,?> consumer)
      Invoked with data from kafka, an acknowledgment, and provides access to the consumer. When explicit acknowledgment mode is used, the acknowledgment parameter will be non-null and must be used to acknowledge the record. When implicit acknowledgment mode is used, the acknowledgment parameter will be null.
      Parameters:
      data - the data to be processed.
      acknowledgment - the acknowledgment (nullable in implicit mode).
      consumer - the consumer.
    • onMessage

      default void onMessage(org.apache.kafka.clients.consumer.ConsumerRecord<K,V> data)
      Description copied from interface: GenericMessageListener
      Invoked with data from kafka.
      Specified by:
      onMessage in interface GenericMessageListener<K>
      Parameters:
      data - the data to be processed.