Consumer维护OffSet的接口是:OffsetStore,有俩个实现类
- RemoteBrokerOffsetStore:消息模式是Cluster会用到它
- LocalFileOffsetStore:消息模式是BoardCast会用到它
我们以RemoteBrokerOffsetStore为例来看读取offset的顺序
RemoteBrokerOffsetStore读取offset的顺序
1 | public long readOffset(final MessageQueue mq, final ReadOffsetType type) { |
当需要从broker读取的时候调用fetchConsumeOffsetFromBroker
1 | private long fetchConsumeOffsetFromBroker(MessageQueue mq) throws RemotingException, MQBrokerException, |
broker处理QUERY_CONSUMER_OFFSET请求的逻辑
从ConsumerQueue中获取offset
1 | private RemotingCommand queryConsumerOffset(ChannelHandlerContext ctx, RemotingCommand request) |