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: [email protected] With regards, Apache Git Services
