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. (#20416)
  • Loading branch information
lifepuzzlefun authored May 29, 2023
1 parent 0bdcaec commit fafadee
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1048,8 +1048,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 fafadee

Please sign in to comment.