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/03/02 06:16:53 UTC

[GitHub] [rocketmq] wuqinghai opened a new issue #1815: When consuming a batch of messages, some messages cannot be rolled back, only all messages can be rolled back

wuqinghai opened a new issue #1815: When consuming a batch of messages, some messages cannot be rolled back, only all messages can be rolled back
URL: https://github.com/apache/rocketmq/issues/1815
 
 
   Consumer code:
   consumer.registerMessageListener(new MessageListenerConcurrently() {
               @Override
               public ConsumeConcurrentlyStatus consumeMessage(List<MessageExt> msgs,
                                                               ConsumeConcurrentlyContext context) {
                   System.out.println("接收新消息的线程: "+ Thread.currentThread().getName() +",消息数: "+msgs.size());
                   for (int i = 0; i < msgs.size(); i++) {
                       MessageExt ext = msgs.get(i);
                       if (i ==5) {
                           System.out.println("第"+(i)+"条消息消费失败,需要重试");
                           context.setAckIndex(i);
                           return ConsumeConcurrentlyStatus.RECONSUME_LATER;
                       }
                       System.out.println("第"+(i)+"条消息消费成功,"+ ext.getTopic()+":"+new String(ext.getBody(), Charset.forName("utf-8")));
                   }
                   return ConsumeConcurrentlyStatus.CONSUME_SUCCESS;
               }
           });
    
   
   if consumer return ConsumeConcurrentlyStatus.RECONSUME_LATER, Consermer'll get all the news of msgs.
   
   Why do you write like this?
   Why reset it to - 1?
   org.apache.rocketmq.client.impl.consumer.ConsumeMessageConcurrentlyService#processConsumeResult
   switch (status) {
               case CONSUME_SUCCESS:
                   if (ackIndex >= consumeRequest.getMsgs().size()) {
                       ackIndex = consumeRequest.getMsgs().size() - 1;
                   }
                   int ok = ackIndex + 1;
                   int failed = consumeRequest.getMsgs().size() - ok;
                   this.getConsumerStatsManager().incConsumeOKTPS(consumerGroup, consumeRequest.getMessageQueue().getTopic(), ok);
                   this.getConsumerStatsManager().incConsumeFailedTPS(consumerGroup, consumeRequest.getMessageQueue().getTopic(), failed);
                   break;
               case RECONSUME_LATER:
                   ackIndex = -1;
                   this.getConsumerStatsManager().incConsumeFailedTPS(consumerGroup, consumeRequest.getMessageQueue().getTopic(),
                       consumeRequest.getMsgs().size());
                   break;
               default:
                   break;
           }
   

----------------------------------------------------------------
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


With regards,
Apache Git Services

[GitHub] [rocketmq] duhenglucky closed issue #1815: 当消费一批消息时如20条,中间的第5条出现问题,直接返回ConsumeConcurrentlyStatus.RECONSUME_LATER,设置ackIndex为4后,还是会收到全部的20条消息进行重试,为什么不是收到acdIndex后面的消息?

Posted by GitBox <gi...@apache.org>.
duhenglucky closed issue #1815: 当消费一批消息时如20条,中间的第5条出现问题,直接返回ConsumeConcurrentlyStatus.RECONSUME_LATER,设置ackIndex为4后,还是会收到全部的20条消息进行重试,为什么不是收到acdIndex后面的消息?
URL: https://github.com/apache/rocketmq/issues/1815
 
 
   

----------------------------------------------------------------
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


With regards,
Apache Git Services

[GitHub] [rocketmq] duhenglucky commented on issue #1815: 当消费一批消息时如20条,中间的第5条出现问题,直接返回ConsumeConcurrentlyStatus.RECONSUME_LATER,设置ackIndex为4后,还是会收到全部的20条消息进行重试,为什么不是收到acdIndex后面的消息?

Posted by GitBox <gi...@apache.org>.
duhenglucky commented on issue #1815: 当消费一批消息时如20条,中间的第5条出现问题,直接返回ConsumeConcurrentlyStatus.RECONSUME_LATER,设置ackIndex为4后,还是会收到全部的20条消息进行重试,为什么不是收到acdIndex后面的消息?
URL: https://github.com/apache/rocketmq/issues/1815#issuecomment-593700589
 
 
   @wuqinghai 还是希望降低用户的使用门槛,返回一个值就够了,大部分时候,在没有消费堆积的情况下,每一批的量是很少的。
   issue一般用作bug fix或者是feature request,相关的讨论最好还是在邮件列表里面,这样能够沉淀下来,而且被搜索到:),可以订阅一下:https://rocketmq.apache.org/about/contact/

----------------------------------------------------------------
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


With regards,
Apache Git Services