codelipenghui opened a new pull request #3079: Fix
URL: https://github.com/apache/pulsar/pull/3079
 
 
   ### Motivation
   #### Expected behavior
   
   User process the same message many times but failed, if user set a dead 
letter policy, when message process times exceed the max redelivery count in 
dead letter policy, message will send to the dead letter topic.
   
   #### Actual behavior
   
   When a consumer subscribe a topic, but wait a while then start receive 
messages, but messages already send to dead letter topic.
   
   #### Steps to reproduce
   
   Here is the code to reproduce
   
   ```java
   public class RedeliveryIssue {
   
       public static void main(String[] args) throws PulsarClientException, 
InterruptedException {
   
           final String topic = "my-topic";
   
           PulsarClient client = PulsarClient.builder()
                   .serviceUrl("pulsar://localhost:6650")
                   .build();
   
           Consumer<byte[]> consumer = client.newConsumer()
                   .topic(topic)
                   .subscriptionType(SubscriptionType.Shared)
                   .subscriptionName(UUID.randomUUID().toString())
                   .ackTimeout(3, TimeUnit.SECONDS)
                   
.deadLetterPolicy(DeadLetterPolicy.builder().maxRedeliverCount(2).build())
                   .subscribe();
   
           Producer<byte[]> producer = client.newProducer()
                   .topic(topic)
                   .create();
   
           producer.send(("a message").getBytes());
   
           // wait a while, message will send to dead letter topic
           Thread.sleep(10000L);
   
           do {
               // can't receive message
               Message<byte[]> msg = consumer.receive();
               System.out.println(new String(msg.getValue()));
           } while (true);
       }
   }
   ```
   
   #### System configuration
   **Pulsar version**: 2.2.0
   
   ### Modifications
   
   Remove un-ack message tracking on message received.
   Add un-ack message tracking on consumer call receive
   
   ### Result
   
   UT passed

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to