The consumer receives the same message again after executing the acknowledge interface
- Dominant language
- Java
- Stars
- 15.3k
- Forks
- 3.8k
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 142
Description
**Describe the bug**
We found a problem with pulsar consumer ack in our test. The producer sends 1W messages. We use the consumer's acknowledge interface to submit the offset. When we start the consumer process to consume a part of the message, we kill the process and start the same consumer process again to consume the message. The message that has executed the acknowledge interface before killing will be received, It leads to the repetition of consumption.
pulsar v2.6.2
consumer code:
```
ConsumerBuilder consumerBuilder = getClient().newConsumer(Schema.STRING);
List topics = new ArrayList<>();
topics.add("persistent://public/default/test-string5");
consumerBuilder.topics(topics)
.subscriptionName("consumerSych")
.subscriptionType(SubscriptionType.Shared)
.subscriptionInitialPosition(SubscriptionInitialPosition.Earliest);
Consumer consumer = consumerBuilder.subscribe();
while (true) {
Message msg = consumer.receive();
consumer.acknowledge(msg);
System.out.println("ack message:" + msg.getMessageId().toString());
}
```
Contributor guide
Research direction
Start with the Java consumer snippet and the acknowledge behavior in Pulsar 2.6.2. Reproduce the sequence of acknowledging messages, killing the consumer, and restarting it, then inspect the relevant consumer acknowledgment and redelivery behavior. Done means the cause of the repeated acknowledged message is identified and the issue has a verified fix or documented expected behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- distributed-systems
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100