Class OrderedStreamHandler
- All Implemented Interfaces:
KafkaCommitHandler
KafkaCommitHandler wrapper that applies ordering guarantees for concurrent processing.
Messages are grouped (by key or partition) and each group processes messages sequentially, while different groups can process concurrently. All other commit handler operations are delegated to the underlying handler.
This strategy supports concurrent processing with ordering guarantees using the
`throttled.ordered` configuration. Messages are grouped (by key or partition)
and each group processes messages sequentially, while different groups can process
concurrently. See ProcessingOrder for available modes.
This decorator works with any commit strategy, but it is particularly useful with the throttled strategy,
as it allows to process messages in order while still benefiting from concurrency.
- See Also:
-
Nested Class Summary
Nested 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
ConstructorsConstructorDescriptionOrderedStreamHandler(KafkaConnectorIncomingConfiguration configuration, io.vertx.mutiny.core.Vertx vertx, KafkaConsumer<?, ?> consumer, KafkaCommitHandler delegate, ProcessingOrder processingOrder) -
Method Summary
Modifier and TypeMethodDescriptionvoidcapture(io.vertx.core.Context context) voidcapture(io.vertx.mutiny.core.Context context) <K,V> io.smallrye.mutiny.Multi <IncomingKafkaRecord<K, V>> decorateStream(io.smallrye.mutiny.Multi<IncomingKafkaRecord<K, V>> consumed) Decorates the stream of consumed Kafka records.Returns the underlying commit handler.<K,V> io.smallrye.mutiny.Uni <Void> handle(IncomingKafkaRecord<K, V> record) Handle message acknowledgmentvoidpartitionsAssigned(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 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
getContext, getTimeoutInMillis, runOnContext, runOnContextAndAwait
-
Constructor Details
-
OrderedStreamHandler
public OrderedStreamHandler(KafkaConnectorIncomingConfiguration configuration, io.vertx.mutiny.core.Vertx vertx, KafkaConsumer<?, ?> consumer, KafkaCommitHandler delegate, ProcessingOrder processingOrder)
-
-
Method Details
-
capture
public void capture(io.vertx.mutiny.core.Context context) - Overrides:
capturein classContextHolder
-
capture
public void capture(io.vertx.core.Context context) - Overrides:
capturein classContextHolder
-
decorateStream
public <K,V> io.smallrye.mutiny.Multi<IncomingKafkaRecord<K,V>> decorateStream(io.smallrye.mutiny.Multi<IncomingKafkaRecord<K, V>> consumed) Description copied from interface:KafkaCommitHandlerDecorates the stream of consumed Kafka records.This method allows commit handlers to transform the incoming stream of records
- Specified by:
decorateStreamin interfaceKafkaCommitHandler- Type Parameters:
K- type of record keyV- type of record value- Parameters:
consumed- the stream of consumed Kafka records- Returns:
- the decorated stream of Kafka records
-
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
-
partitionsAssigned
Description copied from interface:KafkaCommitHandlerCalled on partitions assigned on Kafka rebalance listener- Specified by:
partitionsAssignedin interfaceKafkaCommitHandler- Parameters:
partitions- assigned partitions
-
partitionsRevoked
Description copied from interface:KafkaCommitHandlerCalled on partitions revokd on Kafka rebalance listener- Specified by:
partitionsRevokedin interfaceKafkaCommitHandler- Parameters:
partitions- revoked partitions
-
getDelegate
Returns the underlying commit handler.
-