Spring STOMP sending messages from anywhere in the application

跟風遠走 提交于 2019-12-04 07:25:21

As correctly written in the comments, there are multiple ways to autowire dependencies, they are mostly equivalent, you have to choose the ones you prefer depending on your needs.

As per the other question: in Spring the controller is the object (a singleton) that listen to user requests, so the mapping @RequestMapping handles HTTP requests to the designated url.

If you need to push messages from the server to the client using the SimpMessagingTemplate object you must know that the client must using the STOMP protocol (over websockets), and it must be subscribed to the right topic.

In fact using STOMP the server can't push arbitrarily messages to the client, but it can only publish messages to topics, and the client must be subscribed to the right topics to receive them.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!