davsclaus commented on code in PR #26779:
URL: https://github.com/apache/camel/pull/26779#discussion_r4083534919


##########
components/camel-pulsar/src/main/java/org/apache/camel/component/pulsar/PulsarMessageListener.java:
##########
@@ -73,4 +73,15 @@ private void acknowledge(final Consumer<byte[]> consumer, 
final Message<byte[]>
         }
     }
 
+    /**
+     * Tells the broker the message was not processed, so that it is 
redelivered after
+     * <tt>negativeAckRedeliveryDelayMicros</tt> instead of waiting for the 
acknowledgement timeout. Left to the route
+     * when manual acknowledgement is enabled, the same way {@link 
#acknowledge} is.
+     */
+    private void negativeAcknowledge(final Consumer<byte[]> consumer, final 
Message<byte[]> message) {
+        if (!endpoint.getPulsarConfiguration().isAllowManualAcknowledgement()) 
{
+            consumer.negativeAcknowledge(message.getMessageId());

Review Comment:
   Please pass the message itself here. In pulsar-client, 
`negativeAcknowledge(MessageId)` records redelivery count 0, while 
`negativeAcknowledge(Message)` passes `message.getRedeliveryCount()` to 
`negativeAckRedeliveryBackoff.next(count)`. With the id only, a configured 
backoff always uses its first delay and never grows, which contradicts the 
upgrade guide.
   
   ```suggestion
               consumer.negativeAcknowledge(message);
   ```
   
   The verify in `PulsarMessageListenerAcknowledgementTest` (line 78) then 
needs to expect the message instead of `messageId`.



##########
docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_23.adoc:
##########
@@ -2580,3 +2580,17 @@ Routes that reference the constants (for example 
`setHeader(MustacheConstants.MU
 are unaffected. Routes that set the header by its literal string name, or that 
use
 `allowTemplateFromHeader=true` with the old header names, must switch to the 
new `Camel`-prefixed
 names.
+
+=== camel-pulsar - a failed exchange is negatively acknowledged
+
+When a route fails, the consumer now calls `negativeAcknowledge` on the Pulsar 
consumer instead of
+leaving the message unacknowledged. This only applies when 
`allowManualAcknowledgement` is `false`
+(the default); with manual acknowledgement the route stays in charge, as 
before.
+
+This changes when the message comes back. Previously it was redelivered once 
the acknowledgement
+timeout expired, which `camel-pulsar` sets to 10 seconds by default through 
`ackTimeoutMillis`. A
+negative acknowledgement removes the message from the client's 
unacknowledged-message tracker, so
+redelivery now follows `negativeAckRedeliveryDelayMicros`, which defaults to 
60 seconds, and honours

Review Comment:
   This sentence is only true once the listener passes the `Message` to 
`negativeAcknowledge` (see the comment in `PulsarMessageListener`).



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