Repository: activemq-artemis
Updated Branches:
  refs/heads/master 09f9159ea -> 4109ffc0c


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.


Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/960833d2
Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/960833d2
Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/960833d2

Branch: refs/heads/master
Commit: 960833d2be6cfd632334e7a81b042ea7281d3fdc
Parents: 09f9159
Author: Timothy Bish <tabish...@gmail.com>
Authored: Tue Aug 28 16:11:14 2018 -0400
Committer: Robbie Gemmell <rob...@apache.org>
Committed: Wed Aug 29 10:51:18 2018 +0100

----------------------------------------------------------------------
 .../protocol/amqp/proton/ProtonServerReceiverContext.java        | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/960833d2/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/proton/ProtonServerReceiverContext.java
----------------------------------------------------------------------
diff --git 
a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/proton/ProtonServerReceiverContext.java
 
b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/proton/ProtonServerReceiverContext.java
index c3df1a7..e54a1a5 100644
--- 
a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/proton/ProtonServerReceiverContext.java
+++ 
b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/proton/ProtonServerReceiverContext.java
@@ -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 {

Reply via email to