Modern C++ Kafka API
|
The queue can be used to determine the right offset to commit. More...
#include <UnorderedOffsetCommitQueue.h>
Public Member Functions | |
UnorderedOffsetCommitQueue (const Topic &topic, Partition partition) | |
std::size_t | size () const |
Return how many received offsets have not been popped to commit (with popOffsetToCommit() ). | |
void | waitOffset (Offset offset) |
Add an offset (for a ConsumerRecord) to the waiting list, until it being acked (with ackOffset ). More... | |
void | ackOffset (Offset offset) |
Ack the record has been handled and ready to be committed. More... | |
Optional< Offset > | popOffsetToCommit () |
Pop the offset which is ready for the consumer (if any). | |
Optional< Offset > | lastPoppedOffset () |
Return the offset last popped. | |
The queue can be used to determine the right offset to commit.
A KafkaManuallyCommitConsumer
might forward the received records to different handlers, while these handlers could not ack the records in order. Then, the UnorderedOffsetCommitQueue
would help,
UnorderedOffsetCommitQueue
for each topic-partition.waitOffset()
for each record received.ackOffset()
while a handler acks for an record.popOffsetToCommit()
and commit the offset then.
|
inline |
Ack the record has been handled and ready to be committed.
Note: If all offsets ahead has been acked, then with popOffsetToCommit()
, we'd get offset + 1
, which is ready to be committed for the consumer.
|
inline |
Add an offset (for a ConsumerRecord) to the waiting list, until it being acked (with ackOffset
).
Note: Make sure the offset would be ack
later with ackOffset()
.