0

I use SpringMVC 4 + Tomcat. My application has got 2 classes (A and B) with @Autowired SimpMessagingTemplate. Each class has got a thread that calls "convertAndSend".

Class A sends a message that consists of 8 double fields and 3 long ones. It sends messages to approx. 500 topics like "/topic/prices.X" (where X - some random string). Frequency - up to 4 times per second (for each topic) in a single loop.

Class B sends a message that consists of 8 double fields, 4 long and 4 String ones. It sends messages to a singe topic like "/topic/dmaEvents". Frequency - several times a second (can be up to 20 times).

For my application it is extremely important to preserve messages order, so I applied a solution described here:

SockJS receive stomp messages from spring websocket out of order

@Override
public void configureClientInboundChannel(ChannelRegistration registration) {
     registration.taskExecutor().corePoolSize(1);
}

We have about 10-20 clients connected simultaneously and subscribed to all topics. Client application - .Net one that uses the "websocket-sharp" library with a custom implementation of STOMP protocol. Server is in NY, clients are in Chicago and London.

Everything works fine at our UAT environment, but in the prod one users complain about the following issue:

  • Under some circumstances messages from the Class B are delivered to the clients with a delay about 30-40 seconds. In the same time messages from the Class A are delivered without any delay. This occurs when the frequency of messages from the Class A are being sent with max frequency (4 times per second for each topic = 2000 messages per second). When the frequency decreases the delays disappear.

I marked every message with a sequenceId and noticed that messages from the ClassB are delivered in a wrong order anyway. For example, a server sends:

  • message1 -> /topic/prices.A
  • message2 -> /topic/prices.B
  • message3 -> /topic/dmaEvents
  • message4 -> /topic/prices.C
  • message5 -> /topic/prices.D

The client receives:

  • message1 -> /topic/prices.A
  • message2 -> /topic/prices.B
  • message4 -> /topic/prices.C
  • message5 -> /topic/prices.D
  • message3 -> /topic/dmaEvents

Question1: It that an expected behaviour?

Question2: What may be a reason of that delays? Should I get rid of the solution with registration.taskExecutor().corePoolSize(1); and implement a logic that will guard messages order on the client side?

Thank you.

1 Answers1

1

i had a similar issues with stalled/slow delivery of STOMP messages which turned out to be caused by the reactor library used in spring.

updating it to a later version fixed it for me:

runtime("io.projectreactor:reactor-core:2.0.6.RELEASE")
runtime("io.projectreactor:reactor-net:2.0.6.RELEASE")
runtime("io.netty:netty-all:4.0.33.Final")
light_303
  • 2,101
  • 2
  • 18
  • 35