Class KafkaCheckpointCommit
- java.lang.Object
-
- io.smallrye.reactive.messaging.kafka.commit.ContextHolder
-
- io.smallrye.reactive.messaging.kafka.commit.KafkaCheckpointCommit
-
- All Implemented Interfaces:
KafkaCommitHandler
@Experimental("Experimental API") public class KafkaCheckpointCommit extends ContextHolder implements KafkaCommitHandlerCommit handler for checkpointing processing state persisted in a state storeInstead of committing topic-partition offsets back to Kafka, checkpointing commit handlers persist and restore offsets on an external store. It associates a
ProcessingStatewith a topic-partition offset, and lets the processing resume from the checkpointed state.This abstract implementation holds a local map of
ProcessingStateper topic-partition, and ensures it is accessed on the captured Vert.x context.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classKafkaCheckpointCommit.CheckpointState<T>static classKafkaCheckpointCommit.Factorystatic classKafkaCheckpointCommit.LastStateStoredTooLongAgoException-
Nested classes/interfaces inherited from interface io.smallrye.reactive.messaging.kafka.commit.KafkaCommitHandler
KafkaCommitHandler.Strategy
-
-
Field Summary
-
Fields inherited from class io.smallrye.reactive.messaging.kafka.commit.ContextHolder
context, vertx
-
-
Constructor Summary
Constructors Constructor Description KafkaCheckpointCommit(io.vertx.mutiny.core.Vertx vertx, KafkaConsumer<?,?> consumer, CheckpointStateStore stateStore, BiConsumer<Throwable,Boolean> reportFailure, int autoCommitInterval, int unsynchedStateMaxAge, int defaultTimeout)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <K,V>
io.smallrye.mutiny.Uni<Void>handle(IncomingKafkaRecord<K,V> record)Called on Vert.x event loopvoidpartitionsAssigned(Collection<org.apache.kafka.common.TopicPartition> partitions)Called on partitions assigned on Kafka rebalance listenervoidpartitionsRevoked(Collection<org.apache.kafka.common.TopicPartition> partitions)Called on partitions revokd on Kafka rebalance listener<K,V>
io.smallrye.mutiny.Uni<IncomingKafkaRecord<K,V>>received(IncomingKafkaRecord<K,V> record)Called on Vert.x event loopvoidterminate(boolean graceful)Called on channel shutdown-
Methods inherited from class io.smallrye.reactive.messaging.kafka.commit.ContextHolder
capture, capture, getContext, getTimeoutInMillis, runOnContext, runOnContextAndAwait
-
-
-
-
Constructor Detail
-
KafkaCheckpointCommit
public KafkaCheckpointCommit(io.vertx.mutiny.core.Vertx vertx, KafkaConsumer<?,?> consumer, CheckpointStateStore stateStore, BiConsumer<Throwable,Boolean> reportFailure, int autoCommitInterval, int unsynchedStateMaxAge, int defaultTimeout)
-
-
Method Detail
-
received
public <K,V> io.smallrye.mutiny.Uni<IncomingKafkaRecord<K,V>> received(IncomingKafkaRecord<K,V> record)
Called on Vert.x event loop- 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
public <K,V> io.smallrye.mutiny.Uni<Void> handle(IncomingKafkaRecord<K,V> record)
Called on Vert.x event loop- 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
-
partitionsAssigned
public void partitionsAssigned(Collection<org.apache.kafka.common.TopicPartition> partitions)
Description copied from interface:KafkaCommitHandlerCalled on partitions assigned on Kafka rebalance listener- Specified by:
partitionsAssignedin interfaceKafkaCommitHandler- Parameters:
partitions- assigned partitions
-
partitionsRevoked
public void partitionsRevoked(Collection<org.apache.kafka.common.TopicPartition> partitions)
Description copied from interface:KafkaCommitHandlerCalled on partitions revokd on Kafka rebalance listener- Specified by:
partitionsRevokedin interfaceKafkaCommitHandler- Parameters:
partitions- revoked partitions
-
-