Handle STOMP messages from client in order

See gh-21798
This commit is contained in:
rstoyanchev
2023-10-09 17:28:15 +01:00
parent 4195e6906c
commit a205eab618
6 changed files with 133 additions and 46 deletions

View File

@@ -113,7 +113,12 @@ public class OrderedMessageChannelDecorator implements MessageChannel {
}
}
/**
* Remove the message from the top of the queue, but only if it matches,
* i.e. hasn't been removed already.
*/
private boolean removeMessage(Message<?> message) {
// Remove only if not removed already
Message<?> next = this.messages.peek();
if (next == message) {
this.messages.remove();
@@ -181,7 +186,7 @@ public class OrderedMessageChannelDecorator implements MessageChannel {
@Override
public void run() {
if (this.handledCount == null || this.handledCount.addAndGet(1) == subscriberCount) {
if (OrderedMessageChannelDecorator.this.removeMessage(message)) {
if (OrderedMessageChannelDecorator.this.removeMessage(this.message)) {
sendNextMessage();
}
}