forked from apache/pulsar
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change un-ack messages start tracking behavior (apache#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
- Loading branch information
1 parent
8cd900c
commit 5d06b1e
Showing
3 changed files
with
51 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters