Skip to content

Commit

Permalink
Add log to track negtive unacked msg. (#14501)
Browse files Browse the repository at this point in the history
(cherry picked from commit 82bbb2c)
  • Loading branch information
Technoboy- authored and codelipenghui committed Mar 12, 2022
1 parent e0d2f20 commit fd5bc9d
Showing 1 changed file with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@ public class Consumer {
@Setter
private volatile long consumerEpoch;

private long negtiveUnackedMsgsTimestamp;

public Consumer(Subscription subscription, SubType subType, String topicName, long consumerId,
int priorityLevel, String consumerName,
boolean isDurable, TransportCnx cnx, String appId,
Expand Down Expand Up @@ -947,6 +949,10 @@ private int addAndGetUnAckedMsgs(Consumer consumer, int ackedMessages) {
subscription.addUnAckedMessages(ackedMessages);
unackedMsgs = UNACKED_MESSAGES_UPDATER.addAndGet(consumer, ackedMessages);
}
if (unackedMsgs < 0 && System.currentTimeMillis() - negtiveUnackedMsgsTimestamp >= 10_000) {
negtiveUnackedMsgsTimestamp = System.currentTimeMillis();
log.warn("unackedMsgs is : {}, ackedMessages : {}, consumer : {}", unackedMsgs, ackedMessages, consumer);
}
return unackedMsgs;
}

Expand Down

0 comments on commit fd5bc9d

Please sign in to comment.