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.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classNested classes/interfaces inherited from interface io.smallrye.reactive.messaging.kafka.commit.KafkaCommitHandler
KafkaCommitHandler.Factory, KafkaCommitHandler.Strategy -
Field Summary
Fields inherited from class io.smallrye.reactive.messaging.kafka.commit.ContextHolder
context, vertx -
Constructor Summary
ConstructorsConstructorDescriptionKafkaShareGroupCommit(KafkaShareConsumer<?, ?> consumer, io.vertx.mutiny.core.Vertx vertx, int defaultTimeout, int autoCommitInterval, int processingTimeout, BiConsumer<Throwable, Boolean> reportFailure) -
Method Summary
Modifier and TypeMethodDescription<K,V> io.smallrye.mutiny.Uni <Void> handle(IncomingKafkaRecord<K, V> record) Handle message acknowledgmentvoidonComplete(Map<org.apache.kafka.common.TopicIdPartition, Set<Long>> offsets, Exception exception) Callback for acknowledgement commit completion.<K,V> io.smallrye.mutiny.Uni <IncomingKafkaRecord<K, V>> received(IncomingKafkaRecord<K, V> record) Called on message received but before calling the processing function.voidterminate(boolean graceful) Called on channel shutdownMethods inherited from class io.smallrye.reactive.messaging.kafka.commit.ContextHolder
capture, capture, getContext, getTimeoutInMillis, runOnContext, runOnContextAndAwaitMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.smallrye.reactive.messaging.kafka.commit.KafkaCommitHandler
decorateStream, partitionsAssigned, partitionsRevoked
-
Constructor Details
-
Method Details
-
received
public <K,V> io.smallrye.mutiny.Uni<IncomingKafkaRecord<K,V>> received(IncomingKafkaRecord<K, V> record) Description copied from interface:KafkaCommitHandlerCalled on message received but before calling the processing function. ReturnedUniallows chaining asynchronous actions before message processing.- Specified by:
receivedin interfaceKafkaCommitHandler- Type Parameters:
K- type of record keyV- type of record value- Parameters:
record- incoming Kafka record- Returns:
- the
Uniyielding the received record
-
handle
Description copied from interface:KafkaCommitHandlerHandle message acknowledgment- Specified by:
handlein interfaceKafkaCommitHandler- Type Parameters:
K- type of record keyV- 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:KafkaCommitHandlerCalled on channel shutdown- Specified by:
terminatein interfaceKafkaCommitHandler- Parameters:
graceful-trueif 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:
onCompletein interfaceorg.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.
-