cppkafka icon indicating copy to clipboard operation
cppkafka copied to clipboard

How Could the consumer consume the message from any offset I specilized after it restart?

Open XueRonger opened this issue 5 years ago • 3 comments

XueRonger avatar Apr 30 '20 11:04 XueRonger

You can use assign() to specify which offsets you want to start reading from. This can be either called directly if you have a static consumer or from the rebalance callback when the broker assigns the partitions to your consumer dynamically.

accelerated avatar May 01 '20 16:05 accelerated

You can use assign() to specify which offsets you want to start reading from. This can be either called directly if you have a static consumer or from the rebalance callback when the broker assigns the partitions to your consumer dynamically.

Thanks a lot! Another way is to use consumer.set_assignment_callback() , in fact it will use assign() at the end of this callback function.

XueRonger avatar May 05 '20 16:05 XueRonger

@XueRonger correct. In the assignment callback you can edit the partitions and specify the exact offsets, since this is done before the call to assign().

accelerated avatar May 05 '20 18:05 accelerated