使用STOMP订阅主题Spring WebSocket时未创建动态队列?
我正在为订阅特定事件的所有用户子集开发推送通知。 用户订阅RabbitMQ中的主题,格式为:User-id.event-type.id。 我使用SpringWebSocket、Stomp、RabbitMQ和前端SockJS和Angular JS。 应通知用户有关事件的所有操作(评论等、日期更改) 到目前为止,我们拥有的: 首先,我通过RESTWebService端点进行身份验证,并将令牌放入Cookie。然后我们连接到 websocket。用户订阅topic(/topic/user-45.meeting.1235)并收到通知。但我的问题是一些用户没有收到通知。对于第二个用户,由于某些原因,并没有在RabbitMQ中创建队列。有人知道为什么吗 这是我在Spring applicationContext.xml中的代理设置:使用STOMP订阅主题Spring WebSocket时未创建动态队列?,spring,rabbitmq,stomp,sockjs,spring-websocket,Spring,Rabbitmq,Stomp,Sockjs,Spring Websocket,我正在为订阅特定事件的所有用户子集开发推送通知。 用户订阅RabbitMQ中的主题,格式为:User-id.event-type.id。 我使用SpringWebSocket、Stomp、RabbitMQ和前端SockJS和Angular JS。 应通知用户有关事件的所有操作(评论等、日期更改) 到目前为止,我们拥有的: 首先,我通过RESTWebService端点进行身份验证,并将令牌放入Cookie。然后我们连接到 websocket。用户订阅topic(/topic/user-45.mee
<websocket:message-broker application-destination-prefix="/app">
<websocket:stomp-endpoint path="/stomp">
<websocket:sockjs/>
</websocket:stomp-endpoint>
<websocket:stomp-broker-relay relay-host="localhost" relay-port="61613" system-login="guest" system-passcode="guest" prefix="/queue, /topic"/>
</websocket:message-broker>
更新
若我们在SUBSCRIBE框架中指定unique Id字段,它将为每个用户创建唯一的队列。是这样吗?据我所知,您需要订阅
\queue
而不是\topic
。这样您就不需要为不同的用户自定义主题名称,这将由sockjs根据登录的用户来处理。在服务器端,您还可以使用\queue\user\{username}向特定用户发送消息\{name of queue}
否。不同的计算机。您能用Java(非Websocket)客户端重现“queue not created”错误吗?
var ws = new SockJS('http://' + location.host + path);
var stompClient = Stomp.over(ws);
stompClient.connect({
username: '',
password: '',
host: '/'
}, function () {
stompClient.subscribe('/topic/user-45.meeting.' + obj.id,
function (message) {
console.log(message);
}, {
persistent: true
});
});