public static interface MessageHandler.Context
| Modifier and Type | Method and Description |
|---|---|
long |
committedChunkId()
The ID (offset) of the committed chunk (block of messages) in the stream.
|
Consumer |
consumer()
The consumer that receives the message.
|
long |
offset()
The offset of the message in the stream.
|
void |
processed()
Mark the message as processed, potentially asking for more messages from the broker.
|
void |
storeOffset()
Shortcut to send a store order for the message offset.
|
String |
stream()
The stream the message comes from.
|
long |
timestamp()
The timestamp of the message chunk.
|
long offset()
void storeOffset()
Consumer.store(long)long timestamp()
long committedChunkId()
It is the offset of the first message in the last chunk confirmed by a quorum of the stream cluster members (leader and replicas).
The committed chunk ID is a good indication of what the last offset of a stream can be at a given time. The value can be stale as soon as the application reads it though, as the committed chunk ID for a stream that is published to changes all the time.
This requires RabbitMQ 3.11 or more. The method always returns 0 otherwise.
StreamStats.committedChunkId()String stream()
Consumer consumer()
Consumer.store(long)void processed()
The exact behavior depends on the ConsumerFlowStrategy chosen when creating the
consumer with ConsumerBuilder.flow().
The call is a no-op for strategies like ConsumerFlowStrategy.creditOnChunkArrival() and ConsumerFlowStrategy.creditOnChunkArrival(int).
Calling this method for each message is mandatory for strategies like ConsumerFlowStrategy.creditWhenHalfMessagesProcessed(), ConsumerFlowStrategy.creditWhenHalfMessagesProcessed(int), and ConsumerFlowStrategy.creditOnProcessedMessageCount(int, double), otherwise the broker may
stop sending messages to the consumer.
Applications should make sure to call processed() only once on each context,
as this method does not have to be idempotent. What several calls on the same context does
depends on the underlying ConsumerFlowStrategy implementation.
Copyright © 2024 Broadcom Inc. and/or its subsidiaries. All rights reserved.