xiangwangcheng commented on a change in pull request #1570: [ISSUE 
#1561]support specify msg level reconsume times
URL: https://github.com/apache/rocketmq/pull/1570#discussion_r358095303
 
 

 ##########
 File path: 
client/src/main/java/org/apache/rocketmq/client/impl/consumer/DefaultMQPullConsumerImpl.java
 ##########
 @@ -590,14 +590,25 @@ public void sendMessageBack(MessageExt msg, int 
delayLevel, final String brokerN
             MessageAccessor.setProperties(newMsg, msg.getProperties());
             MessageAccessor.putProperty(newMsg, 
MessageConst.PROPERTY_RETRY_TOPIC, msg.getTopic());
             MessageAccessor.setReconsumeTime(newMsg, 
String.valueOf(msg.getReconsumeTimes() + 1));
-            MessageAccessor.setMaxReconsumeTimes(newMsg, 
String.valueOf(this.defaultMQPullConsumer.getMaxReconsumeTimes()));
+            MessageAccessor.setMaxReconsumeTimes(newMsg, 
String.valueOf(getMaxReconsumeTimes(msg)));
             newMsg.setDelayTimeLevel(3 + msg.getReconsumeTimes());
             this.mQClientFactory.getDefaultMQProducer().send(newMsg);
         } finally {
             msg.setTopic(NamespaceUtil.withoutNamespace(msg.getTopic(), 
this.defaultMQPullConsumer.getNamespace()));
         }
     }
 
+    private int getMaxReconsumeTimes(MessageExt messageExt) {
+        if (messageExt.getMaxReConsumerTimes() >= 0) {
+            return messageExt.getMaxReConsumerTimes();
+        }
+        if (this.defaultMQPullConsumer.getMaxReconsumeTimes() == -1) {
+            return MixAll.DEFAULT_MAX_RECONSUME_TIMES;
 
 Review comment:
   Same as the comment above.

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

Reply via email to