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.
Issue apache#2584: unacked message is not redelivered on time (apache…
…#2590) ### Motivation unacked message is not redelivered after setting ackTimeout, but it is actually redelivered after 2*acktimeout. The main reason is in UnAckedMessageTracker. ``` public void start(PulsarClientImpl client, ConsumerBase<?> consumerBase, long ackTimeoutMillis) { this.stop(); timeout = client.timer().newTimeout(new TimerTask() { @OverRide public void run(Timeout t) throws Exception { if (isAckTimeout()) { < === first timeout, it is false, because oldOpenSet is empty. log.warn("[{}] {} messages have timed-out", consumerBase, oldOpenSet.size()); Set<MessageId> messageIds = new HashSet<>(); oldOpenSet.forEach(messageIds::add); oldOpenSet.clear(); consumerBase.redeliverUnacknowledgedMessages(messageIds); } toggle(); < === toggle after timeout timeout = client.timer().newTimeout(this, ackTimeoutMillis, TimeUnit.MILLISECONDS); } }, ackTimeoutMillis, TimeUnit.MILLISECONDS); } ``` before first timeout, all messageId was added in CurrentSet, not in OldOpenSet, so isAckTimeout() is false, and `redeliverUnacknowledgedMessages` was not called at first timeout. Related issue: apache#2584 ### Modifications - move `toggle()` from behind if clause to before if clause. - add ut ### Result ut passed
- Loading branch information
Showing
4 changed files
with
65 additions
and
43 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
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