Skip to content

Commit

Permalink
[improve] [broker] Avoid PersistentSubscription.expireMessages logi…
Browse files Browse the repository at this point in the history
…c check backlog twice. (apache#20416)

(cherry picked from commit c9eb6bd)
  • Loading branch information
lifepuzzlefun authored and nicoloboschi committed Jul 17, 2023
1 parent f99a67e commit 9f39688
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1046,8 +1046,9 @@ public List<Consumer> getConsumers() {

@Override
public boolean expireMessages(int messageTTLInSeconds) {
if ((getNumberOfEntriesInBacklog(false) == 0) || (dispatcher != null && dispatcher.isConsumerConnected()
&& getNumberOfEntriesInBacklog(false) < MINIMUM_BACKLOG_FOR_EXPIRY_CHECK
long backlog = getNumberOfEntriesInBacklog(false);
if (backlog == 0 || (dispatcher != null && dispatcher.isConsumerConnected()
&& backlog < MINIMUM_BACKLOG_FOR_EXPIRY_CHECK
&& !topic.isOldestMessageExpired(cursor, messageTTLInSeconds))) {
// don't do anything for almost caught-up connected subscriptions
return false;
Expand Down

0 comments on commit 9f39688

Please sign in to comment.