panzhi33 commented on issue #2661: URL: https://github.com/apache/rocketmq/issues/2661#issuecomment-782040855
> 如果第1条消息offset是0,那第0条消息呢。  不好意思,上面图的点位标的有点问题,图在画细一点。可以把consumeQueue每条消息的结构画进去。消息的起始物理偏移量physical offset(long 8字节)+消息大小size(int 4字节)+tagsCode(long 8字节),每条数据的大小为20个字节。使用byteBuffer来存储。 如果是第一条消息,那么它的起始position就是0*20,byteBuffer.getLong()就可以获取到第一条消息的物理位置。那么第二条消息的起始position就是1*20,以此类推。如果按照你那样来算,第5条消息是5的话,起始position就是5*20,通过byteBuffer.getLong()来获取消息的物理位置,就会发生BufferUnderflowException异常了。 重置消费位点确实会发生你说的那个问题,只能重置到倒数第二条。但是mq已经提供了解决办法,如果药重置全部的消息,时间戳哪里设置-1,就不会走getOffsetInQueueByTime这个方法了。 如果你想到解决办法,也可以提pr,一起学习 ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected]
