You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@rocketmq.apache.org by GitBox <gi...@apache.org> on 2020/07/16 09:49:26 UTC

[GitHub] [rocketmq-client-cpp] fluyu commented on issue #322: Consume Offset been Updated Incorrectly with Orderly Push Consumer

fluyu commented on issue #322:
URL: https://github.com/apache/rocketmq-client-cpp/issues/322#issuecomment-659303618


   Seems I might have found some clue.
   
   When the consume orderly service tries to consume the queue([ConsumeMessageOrderlyService.cpp:183](https://github.com/apache/rocketmq-client-cpp/blob/master/src/consumer/ConsumeMessageOrderlyService.cpp#L183)):
   ```cpp
   request->takeMessages(msgs, 1);
   ```
   it may move the only one pending message from `m_msgTreeMap` into `m_msgTreeMapTemp`, which makes the next pull consider all messages been consumed in the queue([DefaultMQPushConsumerImpl.cpp:100](https://github.com/apache/rocketmq-client-cpp/blob/79c278cbad0b2dfaf42a1d7e79b12a57f718c73c/src/consumer/DefaultMQPushConsumerImpl.cpp#L100), [DefaultMQPushConsumerImpl.cpp:122](https://github.com/apache/rocketmq-client-cpp/blob/79c278cbad0b2dfaf42a1d7e79b12a57f718c73c/src/consumer/DefaultMQPushConsumerImpl.cpp#L122)):
   ```cpp
   pullRequest->getMessage(msgs);
   if ((msgs.size() == 0) && (result.nextBeginOffset > 0)) {
     m_callbackOwner->updateConsumeOffset(pullRequest->m_messageQueue, result.nextBeginOffset);
   }
   ```
   thus updating the consume progress wrongly.
   
   This logic will only occur when there's olny one message to be consumed in the queue and consumer orderly is used, which matches my use case nicely.
   
   For now I have changed the `PullRequest::getMessage` function to return messages in both `m_msgTreeMap` and `m_msgTreeMapTemp`, is this change sane? Any potential bug here?


----------------------------------------------------------------
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:
users@infra.apache.org