在开发中收到调用seek方法指定偏移量时,报了如下错误:
java.lang.IllegalStateException: No current assignment for partition xxx
报错的意思是该分区没有你指定的那个偏移量,但是在Kafka可视化工具上看,明明有那个偏移量,为何会报这个错呢。
原来,subscribe()和 assign()是懒惰的-因此,还需要在您可以使用 seek()之前,先对 poll()进行"虚拟调用"。
在开发中收到调用seek方法指定偏移量时,报了如下错误:
java.lang.IllegalStateException: No current assignment for partition xxx
报错的意思是该分区没有你指定的那个偏移量,但是在Kafka可视化工具上看,明明有那个偏移量,为何会报这个错呢。
原来,subscribe()和 assign()是懒惰的-因此,还需要在您可以使用 seek()之前,先对 poll()进行"虚拟调用"。