xuesongxs opened a new issue #14982:
URL: https://github.com/apache/pulsar/issues/14982


   **Describe the bug**
   Pulsar v2.8.3
   acknowledgmentAtBatchIndexLevelEnabled will still receive duplicate messages
   
   **To Reproduce**
   Steps to reproduce the behavior:
   1. Set acknowledgmentAtBatchIndexLevelEnabled=true in broker.conf
   2. Create consumer:
   ```
       public static void main(String[] args) throws Exception{
           PulsarClient client = PulsarClient
                   .builder()
                   .serviceUrl("pulsar://127.0.0.1:6650")
                   .build();
   
           ConsumerBuilder<NlMessage> consumerBuilder = 
client.newConsumer(Schema.JSON(NlMessage.class)).topic("batchtest")
                   .subscriptionName("batchTest")
                   .subscriptionType(SubscriptionType.Shared)
                   .enableRetry(true)
                   .enableBatchIndexAcknowledgment(true)
                   .receiverQueueSize(1000)
                   .negativeAckRedeliveryDelay(20, TimeUnit.SECONDS)
                   
.subscriptionInitialPosition(SubscriptionInitialPosition.Earliest);
           // DLQ
           DeadLetterPolicy deadLetterPolicy = DeadLetterPolicy.builder()
                   .deadLetterTopic("persistent://public/default/batchtest-dlq")
                   
.retryLetterTopic("persistent://public/default/batchtest-retry")
                   .maxRedeliverCount(3)
                   .build();
           consumerBuilder.deadLetterPolicy(deadLetterPolicy);
           consumerBuilder.negativeAckRedeliveryDelay(10, 
TimeUnit.MICROSECONDS);
           consumerBuilder.ackTimeout(0, TimeUnit.SECONDS);
   
           Consumer<NlMessage> consumer = consumerBuilder.subscribe();
           long i = 0;
           while (true) {
               Message<NlMessage> message = consumer.receive();
               System.out.println("message:" + message.getMessageId());
               if (i <= 99) {
                   consumer.acknowledge(message);
                   System.out.println("acked message:" + i);
               } else {
                   // hold the msg
               }
               i++;
           }
   ```
   3. Create producer and send 100 msgs:
   ```
       public static void main(String[] args) throws PulsarClientException {
           PulsarClient pulsarClient = 
PulsarClient.builder().serviceUrl("pulsar://127.0.0.1:6650").build();
           Producer<NlMessage> producer = 
pulsarClient.newProducer(Schema.JSON(NlMessage.class))
                   .topic("persistent://public/default/batchtest")
                   .blockIfQueueFull(true)
                   .sendTimeout(0, TimeUnit.SECONDS)
                   .create();
           long i = 1;
           while(i <= 100L){
               producer.sendAsync(new NlMessage());
               i++;
           }
       }
   ```
   4. 100 msgs in 1 backlog
   
![image](https://user-images.githubusercontent.com/54351417/161229419-14ebd41e-35fa-4fd4-abf2-2ab62097c5a3.png)
   5. After 2 minutes, execute unload cmd:
   `bin/pulsar-admin topics unload persistent://public/default/batchtest
   `
   6. See consumer log, there will also be several or more messages that have 
been ack pushed.
   
   **Expected behavior**
   Only push the message without ack.
   
   **Screenshots**
   If applicable, add screenshots to help explain your problem.
   
   **Desktop (please complete the following information):**
    - OS: [e.g. iOS]
   
   **Additional context**
   Add any other context about the problem here.
   


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