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 store
Instead 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 ClassesModifier and TypeClassDescriptionstatic class
static class
static class
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
ConstructorsConstructorDescriptionKafkaCheckpointCommit
(io.vertx.mutiny.core.Vertx vertx, KafkaConsumer<?, ?> consumer, CheckpointStateStore stateStore, BiConsumer<Throwable, Boolean> reportFailure, int autoCommitInterval, int unsynchedStateMaxAge, int defaultTimeout) -
Method Summary
Modifier and TypeMethodDescription<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 shutdownMethods inherited from class io.smallrye.reactive.messaging.kafka.commit.ContextHolder
capture, capture, getContext, getTimeoutInMillis, runOnContext, runOnContextAndAwait
-
Constructor Details
-
KafkaCheckpointCommit
public KafkaCheckpointCommit(io.vertx.mutiny.core.Vertx vertx, KafkaConsumer<?, ?> consumer, CheckpointStateStore stateStore, BiConsumer<Throwable, Boolean> reportFailure, int autoCommitInterval, int unsynchedStateMaxAge, int defaultTimeout)
-
-
Method Details
-
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
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
Description copied from interface:KafkaCommitHandler
Called on partitions assigned on Kafka rebalance listener- Specified by:
partitionsAssigned
in interfaceKafkaCommitHandler
- Parameters:
partitions
- assigned partitions
-
partitionsRevoked
Description copied from interface:KafkaCommitHandler
Called on partitions revokd on Kafka rebalance listener- Specified by:
partitionsRevoked
in interfaceKafkaCommitHandler
- Parameters:
partitions
- revoked partitions
-