From 493e8892413ab49c39770fcc8c72151ba59b0375 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arnaud=20Cogolu=C3=A8gnes?= Date: Wed, 24 Apr 2024 12:07:37 +0200 Subject: [PATCH] Set echo value if necessary in outgoing flow Setting echo to true can be used to stop gracefully a receiver link before detaching it or just pausing it (see 2.6.10 of spec). --- .../qpid/protonj2/engine/impl/ProtonLinkCreditState.java | 4 ++++ .../org/apache/qpid/protonj2/engine/impl/ProtonReceiver.java | 3 +++ 2 files changed, 7 insertions(+) diff --git a/protonj2/src/main/java/org/apache/qpid/protonj2/engine/impl/ProtonLinkCreditState.java b/protonj2/src/main/java/org/apache/qpid/protonj2/engine/impl/ProtonLinkCreditState.java index 14122586d..9a2558afb 100644 --- a/protonj2/src/main/java/org/apache/qpid/protonj2/engine/impl/ProtonLinkCreditState.java +++ b/protonj2/src/main/java/org/apache/qpid/protonj2/engine/impl/ProtonLinkCreditState.java @@ -120,6 +120,10 @@ public void updateDeliveryCount(int deliveryCount) { this.deliveryCount = deliveryCount; } + public void updateEcho(boolean echo) { + this.echo = echo; + } + void remoteFlow(Flow flow) { remoteDeliveryCount = flow.getDeliveryCount(); remoteLinkCredit = flow.getLinkCredit(); diff --git a/protonj2/src/main/java/org/apache/qpid/protonj2/engine/impl/ProtonReceiver.java b/protonj2/src/main/java/org/apache/qpid/protonj2/engine/impl/ProtonReceiver.java index a0d4bd9b8..b3972a14e 100644 --- a/protonj2/src/main/java/org/apache/qpid/protonj2/engine/impl/ProtonReceiver.java +++ b/protonj2/src/main/java/org/apache/qpid/protonj2/engine/impl/ProtonReceiver.java @@ -446,6 +446,9 @@ protected ProtonReceiver decorateOutgoingFlow(Flow flow) { flow.setDeliveryCount(getCreditState().getDeliveryCount()); } flow.setDrain(isDraining()); + if (getCreditState().isEcho()) { + flow.setEcho(true); + } return this; }