From commits-return-25997-archive-asf-public=cust-asf.ponee.io@pulsar.apache.org Tue Apr 2 17:04:22 2019 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx-eu-01.ponee.io (Postfix) with SMTP id D2B6C180668 for ; Tue, 2 Apr 2019 19:04:21 +0200 (CEST) Received: (qmail 98741 invoked by uid 500); 2 Apr 2019 17:04:21 -0000 Mailing-List: contact commits-help@pulsar.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@pulsar.apache.org Delivered-To: mailing list commits@pulsar.apache.org Received: (qmail 98722 invoked by uid 99); 2 Apr 2019 17:04:20 -0000 Received: from ec2-52-202-80-70.compute-1.amazonaws.com (HELO gitbox.apache.org) (52.202.80.70) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 02 Apr 2019 17:04:20 +0000 From: GitBox To: commits@pulsar.apache.org Subject: [GitHub] [pulsar] lovelle commented on a change in pull request #3962: Feature / Interceptor for negative ack redelivery Message-ID: <155422466039.27192.7697124289246587140.gitbox@gitbox.apache.org> Date: Tue, 02 Apr 2019 17:04:20 -0000 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit lovelle commented on a change in pull request #3962: Feature / Interceptor for negative ack redelivery URL: https://github.com/apache/pulsar/pull/3962#discussion_r271406140 ########## File path: pulsar-client/src/main/java/org/apache/pulsar/client/impl/ConsumerInterceptors.java ########## @@ -109,9 +110,29 @@ public void onAcknowledge(Consumer consumer, MessageId messageId, Throwable e * @param exception exception returned by broker. */ public void onAcknowledgeCumulative(Consumer consumer, MessageId messageId, Throwable exception) { - for (int i = 0; i < interceptors.size(); i++) { + for (ConsumerInterceptor 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. + *

+ * This method calls {@link ConsumerInterceptor#onNegativeAckRedelivery(Consumer, Set)} method for each interceptor. + *

+ * 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 consumer, Set messageIds) { Review comment: Yep, at a first glance I thought exactly that, but later I realise that calling `onNegativeAck()` when `consumer.negativeAcknowledgement()` will occur almost at that very moment (`consumer.negativeAcknowledgement()` just adds the msg to `negativeAckTracker`) and the user could solve this by himself, instead, with adding `onNegativeAckRedelivery()` offers a feature which the user cannot solve right now. The good thing about `onNegativeAck()` is that is consistent with current `onAcknowledge()` existing method. Maybe we want to add both features? and in some future also adding the proper `on*()` method for `UnackMessageTracker`? ---------------------------------------------------------------- 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