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 2020/01/04 08:51:05 UTC

[GitHub] [pulsar] alphashaw opened a new issue #5991: Consumer negative acknowledgement not working

alphashaw opened a new issue #5991: Consumer negative acknowledgement not working
URL: https://github.com/apache/pulsar/issues/5991
 
 
   **Describe the bug**
   According to doc, `When a consumer does not consume a message successfully at a time, and wants to consume the message again, the consumer can send a negative acknowledgement to the broker, and then the broker will redeliver the message.`
   
   If I log the message and **negative-acknowledge** it afterwards, shouldn't it be redeliver back to the consumer on the next **receceive()** poll?
   
   **To Reproduce**
   Below is a simple consumer testing code.
   ```
       Consumer<byte[]> consumer =
           client
               .newConsumer()
               .subscriptionType(SubscriptionType.Key_Shared)
               .subscriptionName("ks-test")
               .topic("test-topic")
               .subscribe();
       while (true) {
         Message<byte[]> message = consumer.receive(100, TimeUnit.MILLISECONDS);
         if (message != null) {
           System.out.println(new String(message.getData()));
           consumer.negativeAcknowledge(message);
         }
       }
   
   ```
   
   **Expected behavior**
   I expect to see the same message reprinted over and over as in the below screenshot
   
   ![correct](https://user-images.githubusercontent.com/14175735/71762980-6f14db80-2ece-11ea-9b61-fa4376fcc354.png)
   
   However, I'm seeing this. No message redelivery. Happens only after `ConsumerBuilder.ackTimeout()` expires. This tells me, the negative acknowledgement is actually not acking. Am I missing something on the consumer API?
   
   ![wrong](https://user-images.githubusercontent.com/14175735/71763005-bdc27580-2ece-11ea-858f-983a0d27e7a9.png)
   
   **Environment**
    - OS: Ubuntu
    - Pulser Vserion: 2.4.1
    - Java Client Version: 2.4.2
   
   
   

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

[GitHub] [pulsar] alphashaw closed issue #5991: Consumer negative acknowledgement not working

Posted by GitBox <gi...@apache.org>.
alphashaw closed issue #5991: Consumer negative acknowledgement not working
URL: https://github.com/apache/pulsar/issues/5991
 
 
   

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

[GitHub] [pulsar] alphashaw commented on issue #5991: Consumer negative acknowledgement not working

Posted by GitBox <gi...@apache.org>.
alphashaw commented on issue #5991: Consumer negative acknowledgement not working
URL: https://github.com/apache/pulsar/issues/5991#issuecomment-570817990
 
 
   Well I just realized that a call to `Consumer#negativeAcknowledge(MessageId)` does not actually trigger the redelivery mechanism but add the `MessageId` to the list of ids to be redeliver. The actual triggering is scheduled by a timer controlled by `ConsumerBuilder#negativeAckRedeliveryDelay()`. 
   
   So, setting this delay to 100ms creates the effect I expected.

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