congbobo184 opened a new issue #10431:
URL: https://github.com/apache/pulsar/issues/10431


   example:
   Transaction abort message1, message2 and then clear incomingMessages.
   after incomingMessage  cleared the message3 can add in incomingMessages. 
This time we cumulativeAck message3 with txn will lose message1 and message2.
   
    
   ```
       @Test
       public void transactionCumulativeAck() throws Exception {
           String topic = NAMESPACE1 + "/txn-timeout";
   
           @Cleanup
           Consumer<String> consumer = pulsarClient.newConsumer(Schema.STRING)
                   .topic(topic)
                   .subscriptionName("test")
                   .subscribe();
   
           @Cleanup
           Producer<String> producer = pulsarClient.newProducer(Schema.STRING)
                   .topic(topic)
                   .sendTimeout(0, TimeUnit.SECONDS)
                   .enableBatching(false)
                   .producerName("txn-timeout")
                   .create();
   
           producer.send("Hello Pulsar one!");
           producer.send("Hello Pulsar two!");
   
           Transaction transaction = pulsarClient
                   .newTransaction()
                   .withTransactionTimeout(3, TimeUnit.SECONDS)
                   .build().get();
   
           Message<String> message = consumer.receive();
   
           System.out.println(message.getValue());
   
           consumer.acknowledgeCumulativeAsync(message.getMessageId(), 
transaction).get();
   
           transaction.abort();
   
           transaction = pulsarClient
                   .newTransaction()
                   .withTransactionTimeout(3, TimeUnit.SECONDS)
                   .build().get();
           // it may receive Hello Pulsar two!
           Message<String> reReceiveMessage = consumer.receive(2, 
TimeUnit.SECONDS);
           System.out.println(reReceiveMessage.getValue());
   
       }
   ```


-- 
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:
[email protected]


Reply via email to