ARTEMIS-2062 Only attempt to refill credit when needed

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.
This commit is contained in:
Timothy Bish 2018-08-28 16:11:14 -04:00 committed by Robbie Gemmell
parent 09f9159eae
commit 960833d2be
1 changed files with 3 additions and 1 deletions

View File

@ -299,7 +299,9 @@ public class ProtonServerReceiverContext extends ProtonInitializable implements
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 {