liudezhi2098 commented on issue #13719:
URL: https://github.com/apache/pulsar/issues/13719#issuecomment-1010784563


   Acknowledgment timeout triggers are triggered when an ACK acknowledgment 
message is not acknowledged within a specified time, such as when an ACK is 
forgotten, or when the business logic takes too long to process.
   `client.newConsumer().ackTimeout(10, TimeUnit.SECOND)` All messages follow 
the same delay strategy.
   
   Negative acknowledgment is when a user actively triggers message retries, 
such as when business logic processing fails and needs to be consumed again, 
All messages follow the same delay strategy.
   ```
   client.newConsumer().negativeAckRedeliveryDelay(1, TimeUnit.SECOND)
   try {
        // Process message...
        consumer.acknowledge(msg);
   } catch (Throwable t) {
        log.warn("Failed to process message");
        consumer.negativeAcknowledge(message);
   }
   
   ```
   
   
   Reconsumelater behaves similarly to negative acknowledgment, different 
places, reconsumeLater will use retry topic to persist retry messages, which 
has the advantage of delaying granular messages at any time, and can 
accommodate a large number of retry message scenarios, this will suit a more 
flexible scenario.
   ```
   try {
        // Process message...
        consumer.acknowledge(msg);
   } catch (Throwable t) {
        log.warn("Failed to process message");
        consumer.reconsumeLater(msg, 1000, TimeUnit.MILLISECONDS);
   }
   ```
   For the user, there is no need to care about the internal implementation 
logic.


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