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 KafkaCommitHandler
Commit 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
ProcessingState
with a topic-partition offset, and lets the processing resume from the checkpointed state.This abstract implementation holds a local map of
ProcessingState
per topic-partition, and ensures it is accessed on the captured Vert.x context.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
KafkaCheckpointCommit.Factory
static class
KafkaCheckpointCommit.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 loopvoid
partitionsAssigned(Collection<org.apache.kafka.common.TopicPartition> partitions)
Called on partitions assigned on Kafka rebalance listenervoid
partitionsRevoked(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 loopvoid
terminate(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:
received
in interfaceKafkaCommitHandler
- Type Parameters:
K
- type of record keyV
- 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)
Called on Vert.x event loop- Specified by:
handle
in 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:KafkaCommitHandler
Called on channel shutdown- Specified by:
terminate
in interfaceKafkaCommitHandler
- Parameters:
graceful
-true
if it is a graceful shutdown
-
partitionsAssigned
public void partitionsAssigned(Collection<org.apache.kafka.common.TopicPartition> partitions)
Description copied from interface:KafkaCommitHandler
Called on partitions assigned on Kafka rebalance listener- Specified by:
partitionsAssigned
in interfaceKafkaCommitHandler
- Parameters:
partitions
- assigned partitions
-
partitionsRevoked
public void partitionsRevoked(Collection<org.apache.kafka.common.TopicPartition> partitions)
Description copied from interface:KafkaCommitHandler
Called on partitions revokd on Kafka rebalance listener- Specified by:
partitionsRevoked
in interfaceKafkaCommitHandler
- Parameters:
partitions
- revoked partitions
-
-