codelipenghui commented on code in PR #17287:
URL: https://github.com/apache/pulsar/pull/17287#discussion_r955747723


##########
pulsar-client/src/main/java/org/apache/pulsar/client/impl/ConsumerImpl.java:
##########
@@ -1386,10 +1386,14 @@ void messageReceived(CommandMessage cmdMessage, ByteBuf 
headersAndPayload, Clien
                             schema, redeliveryCount, consumerEpoch);
             uncompressedPayload.release();
 
-            if (deadLetterPolicy != null && 
possibleSendToDeadLetterTopicMessages != null
-                    && redeliveryCount >= 
deadLetterPolicy.getMaxRedeliverCount()) {
-                possibleSendToDeadLetterTopicMessages.put((MessageIdImpl) 
message.getMessageId(),
-                        Collections.singletonList(message));
+            if (deadLetterPolicy != null && 
possibleSendToDeadLetterTopicMessages != null) {
+                if (redeliveryCount == 
deadLetterPolicy.getMaxRedeliverCount()) {
+                    possibleSendToDeadLetterTopicMessages.put((MessageIdImpl) 
message.getMessageId(),
+                            Collections.singletonList(message));
+                } else if (redeliveryCount > 
deadLetterPolicy.getMaxRedeliverCount()) {
+                    sendMessageToDLQ(message, (MessageIdImpl) 
message.getMessageId(), false);
+                    return;

Review Comment:
   It looks like we can simple change to 
   
   ```
   possibleSendToDeadLetterTopicMessages.put((MessageIdImpl) 
message.getMessageId(),
                               Collections.singletonList(message));
   
redeliverUnacknowledgedMessages(Collections.singleton(message.getMessageId()))
   return;
   ```



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

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to