diff --git a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/AMQPSessionCallback.java b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/AMQPSessionCallback.java index d8c908c327..3dce5dc28f 100644 --- a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/AMQPSessionCallback.java +++ b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/AMQPSessionCallback.java @@ -433,9 +433,11 @@ public class AMQPSessionCallback implements SessionCallback { store.checkMemory(new Runnable() { @Override public void run() { - if (receiver.getRemoteCredit() < threshold) { - receiver.flow(credits); - connection.flush(); + synchronized (connection.getLock()) { + if (receiver.getRemoteCredit() < threshold) { + receiver.flow(credits); + connection.flush(); + } } } });