Skip to content

Commit

Permalink
ARTEMIS-2062 Only attempt to refill credit when needed
Browse files Browse the repository at this point in the history
Avoid firing the offerProducerCredit code when we know that the credit
isnt low enough that a refill is needed, which avoids lock contention
and garbage creation as each inbound message is processed.
  • Loading branch information
tabish121 authored and gemmellr committed Aug 29, 2018
1 parent 09f9159 commit 960833d
Showing 1 changed file with 3 additions and 1 deletion.
Expand Up @@ -299,7 +299,9 @@ public void close(ErrorCondition condition) throws ActiveMQAMQPException {
public void flow(int credits, int threshold) {
// Use the SessionSPI to allocate producer credits, or default, always allocate credit.
if (sessionSPI != null) {
sessionSPI.offerProducerCredit(address, credits, threshold, receiver);
if (receiver.getCredit() <= threshold) {
sessionSPI.offerProducerCredit(address, credits, threshold, receiver);
}
} else {
connection.lock();
try {
Expand Down

0 comments on commit 960833d

Please sign in to comment.