You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2019/04/02 04:58:26 UTC

[GitHub] [pulsar] merlimat commented on a change in pull request #3962: Feature / Interceptor for negative ack redelivery

merlimat commented on a change in pull request #3962: Feature / Interceptor for negative ack redelivery
URL: https://github.com/apache/pulsar/pull/3962#discussion_r271134069
 
 

 ##########
 File path: pulsar-client/src/main/java/org/apache/pulsar/client/impl/ConsumerInterceptors.java
 ##########
 @@ -109,9 +110,29 @@ public void onAcknowledge(Consumer<T> consumer, MessageId messageId, Throwable e
      * @param exception exception returned by broker.
      */
     public void onAcknowledgeCumulative(Consumer<T> consumer, MessageId messageId, Throwable exception) {
-        for (int i = 0; i < interceptors.size(); i++) {
+        for (ConsumerInterceptor<T> interceptor : interceptors) {
             try {
-                interceptors.get(i).onAcknowledgeCumulative(consumer, messageId, exception);
+                interceptor.onAcknowledgeCumulative(consumer, messageId, exception);
+            } catch (Exception e) {
+                log.warn("Error executing interceptor onAcknowledgeCumulative callback ", e);
+            }
+        }
+    }
+
+    /**
+     * This method will be called when a redelivery from a negative acknowledge occurs.
+     * <p>
+     * This method calls {@link ConsumerInterceptor#onNegativeAckRedelivery(Consumer, Set<MessageId>)} method for each interceptor.
+     * <p>
+     * This method does not throw exceptions. Exceptions thrown by any of interceptors in the chain are logged, but not propagated.
+     *
+     * @param consumer the consumer which contains the interceptors
+     * @param messageIds set of messages ids being redelivery.
+     */
+    public void onNegativeAckRedelivery(Consumer<T> consumer, Set<MessageId> messageIds) {
 
 Review comment:
   Regarding the naming of this method, I think it might get a bit misleading because the redelivery might actually get to a different consumer. Eg. ConsumerA calls Nack() and after 1 min ConsumerB will get the message again.
   
   Would it be more intuitive to have the method called `onNegativeAck()` and call it as soon as the app calls `consumer.negativeAcknowledgement()`?

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services