Interface MessageHandler.Context
- Enclosing interface:
MessageHandler
-
Method Summary
Modifier and TypeMethodDescriptionlong
The ID (offset) of the committed chunk (block of messages) in the stream.consumer()
The consumer that receives the message.long
offset()
The offset of the message in the stream.void
Mark the message as processed, potentially asking for more messages from the broker.void
Shortcut to send a store order for the message offset.stream()
The stream the message comes from.long
The timestamp of the message chunk.
-
Method Details
-
offset
long offset()The offset of the message in the stream.- Returns:
- the offset of the current message
-
storeOffset
void storeOffset()Shortcut to send a store order for the message offset.- See Also:
-
timestamp
long timestamp()The timestamp of the message chunk.- Returns:
- the timestamp of the message chunk
-
committedChunkId
long committedChunkId()The ID (offset) of the committed chunk (block of messages) in the stream.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.
- Returns:
- committed chunk ID in this stream
- See Also:
-
stream
String stream()The stream the message comes from.- Returns:
- the stream the message comes from
-
consumer
Consumer consumer()The consumer that receives the message.- Returns:
- the consumer instance
- See Also:
-
processed
void processed()Mark the message as processed, potentially asking for more messages from the broker.The exact behavior depends on the
ConsumerFlowStrategy
chosen when creating the consumer withConsumerBuilder.flow()
.The call is a no-op for strategies like
ConsumerFlowStrategy.creditOnChunkArrival()
andConsumerFlowStrategy.creditOnChunkArrival(int)
.Calling this method for each message is mandatory for strategies like
ConsumerFlowStrategy.creditWhenHalfMessagesProcessed()
,ConsumerFlowStrategy.creditWhenHalfMessagesProcessed(int)
, andConsumerFlowStrategy.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 underlyingConsumerFlowStrategy
implementation.
-