首页 文章

如何保证Java / Spring应用程序上的WebSocket消息顺序[重复]

提问于
浏览
3

这个问题在这里已有答案:

我们目前正在使用Spring的SimpMessagingTemplate将WebSocket消息从服务器发送到客户端 . 我们注意到有时收到的邮件不按规定 .

例:

(Autowired) SimpMessagingTemplate broker
broker.convertAndSend(channelId, "Test1");
broker.convertAndSend(channelId, "Test2");

Client receives:
"Test2"
"Test1"

由于WebSocket是 Build 在TCP / IP之上的,我不明白为什么Spring / SimpMessagingTemplate会破坏这个功能 .

我无法找到有关SimpMessageTemplate消息顺序的任何文档,但有很多关于"full featured message brokers"的评论,例如RabbitMQ和ActiveMQ . RabbitMQ在某些情况下保证消息顺序(不确定它是否适用于Spring应用程序上的WebSocket消息) . 我试图根据this指南进行设置,但 Connection Factory 正在给我一个 "Could not autowire. No beans of Connection Factory type found."

如果我做错了什么,我试着下载并运行教程项目 - 没有't work either. It'只显示"Build succesful",带有一堆看起来像这样的调试打印: 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?

1 回答

相关问题