Class KafkaShareGroupCommit

java.lang.Object
io.smallrye.reactive.messaging.kafka.commit.ContextHolder
io.smallrye.reactive.messaging.kafka.commit.KafkaShareGroupCommit
All Implemented Interfaces:
KafkaCommitHandler, org.apache.kafka.clients.consumer.AcknowledgementCommitCallback

public class KafkaShareGroupCommit extends ContextHolder implements KafkaCommitHandler, org.apache.kafka.clients.consumer.AcknowledgementCommitCallback
Commit Handler for managing the commit lifecycle of messages consumed by a Kafka Share Group consumer. It tracks in-progress messages, handles acknowledgments, and periodically renews locks on messages that are still being processed. It also checks for processing timeouts and reports failures if messages exceed the configured processing time.
  • Constructor Details

    • KafkaShareGroupCommit

      public KafkaShareGroupCommit(KafkaShareConsumer<?,?> consumer, io.vertx.mutiny.core.Vertx vertx, int defaultTimeout, int autoCommitInterval, int processingTimeout, BiConsumer<Throwable,Boolean> reportFailure)
  • Method Details

    • received

      public <K, V> io.smallrye.mutiny.Uni<IncomingKafkaRecord<K,V>> received(IncomingKafkaRecord<K,V> record)
      Description copied from interface: KafkaCommitHandler
      Called on message received but before calling the processing function. Returned Uni allows chaining asynchronous actions before message processing.
      Specified by:
      received in interface KafkaCommitHandler
      Type Parameters:
      K - type of record key
      V - type of record value
      Parameters:
      record - incoming Kafka record
      Returns:
      the Uni yielding the received record
    • handle

      public <K, V> io.smallrye.mutiny.Uni<Void> handle(IncomingKafkaRecord<K,V> record)
      Description copied from interface: KafkaCommitHandler
      Handle message acknowledgment
      Specified by:
      handle in interface KafkaCommitHandler
      Type Parameters:
      K - type of record key
      V - type of record value
      Parameters:
      record - incoming Kafka record
      Returns:
      a completion stage completed when the message is acknowledged.
    • terminate

      public void terminate(boolean graceful)
      Description copied from interface: KafkaCommitHandler
      Called on channel shutdown
      Specified by:
      terminate in interface KafkaCommitHandler
      Parameters:
      graceful - true if it is a graceful shutdown
    • onComplete

      public void onComplete(Map<org.apache.kafka.common.TopicIdPartition,Set<Long>> offsets, Exception exception)
      Callback for acknowledgement commit completion. This is called by the consumer after an acknowledge() call completes, with the offsets that were acknowledged and any exception that occurred during the commit.
      Specified by:
      onComplete in interface org.apache.kafka.clients.consumer.AcknowledgementCommitCallback
      Parameters:
      offsets - A map of the offsets that this callback applies to.
      exception - The exception thrown during processing of the request, or null if the acknowledgement completed successfully.