We're currently using Spring's SimpMessagingTemplate for sending WebSocket messages from server to clients. We noticed that sometimes messages are received out of order.
Example:
(Autowired) SimpMessagingTemplate broker
broker.convertAndSend(channelId, "Test1");
broker.convertAndSend(channelId, "Test2");
Client receives:
"Test2"
"Test1"
Since WebSocket is built on top of TCP/IP, which guarantees order, I don't understand why Spring/SimpMessagingTemplate breaks this functionality.
I wasn't able to find any documentation regarding message order with SimpMessageTemplate, but there are many remarks about "full featured message brokers", such as RabbitMQ and ActiveMQ. RabbitMQ guarantees message order in some instances (not sure if that would apply to WebSocket messages on a Spring app). I tried to set it up according to this guide, but Connection Factory
is giving me a "Could not autowire. No beans of Connection Factory type found."
In case I did something wrong, I tried to just download and run the tutorial project - that didn't work either. It's just showing "Build succesful" with a bunch of debug prints that look like this: DEBUG org.springframework.core.env.PropertySourcesPropertyResolver - Could not find key 'spring.liveBeansView.mbeanDomain' in any property source. Returning [null]
How can I send WebSocket messages from a Spring server without breaking any properties of the protocol?