mfontanini / cppkafka

Modern C++ Apache Kafka client library (wrapper for librdkafka)
BSD 2-Clause "Simplified" License
589 stars 207 forks source link

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

Open XueRonger opened 4 years ago

accelerated commented 4 years ago

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.

XueRonger commented 4 years ago

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.

accelerated commented 4 years ago

@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().