How Could the consumer consume the message from any offset I specilized after it restart?
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.
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 correct. In the assignment callback you can edit the partitions and specify the exact offsets, since this is done before the call to assign().