ARTEMIS-4108 Improving flush on large message fix

This commit is contained in:
Clebert Suconic 2022-12-06 16:07:09 -05:00
parent eb11b044af
commit 33567fca8d
1 changed files with 21 additions and 16 deletions

View File

@ -191,13 +191,22 @@ public class ProtonServerSenderContext extends ProtonInitializable implements Pr
// If the draining is already running, then don't do anything
if (draining.compareAndSet(false, true)) {
final ProtonServerSenderContext plugSender = (ProtonServerSenderContext) serverConsumer.getProtocolContext();
flushDrain(serverConsumer, plugSender);
}
} else {
serverConsumer.receiveCredits(-1);
}
}
private void flushDrain(ServerConsumerImpl serverConsumer, ProtonServerSenderContext plugSender) {
serverConsumer.forceDelivery(1, new Runnable() {
@Override
public void run() {
try {
connection.runNow(() -> {
if (pendingLargeMessage != null) {
afterLargeMessage = () -> drained(plugSender);
// retry the flush after the large message is done
afterLargeMessage = () -> flushDrain(serverConsumer, plugSender);
} else {
drained(plugSender);
}
@ -208,10 +217,6 @@ public class ProtonServerSenderContext extends ProtonInitializable implements Pr
}
});
}
} else {
serverConsumer.receiveCredits(-1);
}
}
private void drained(ProtonServerSenderContext sender) {
sender.reportDrained();