[英]Websockets, SockJs, Stomp, Spring, RabbitMQ, delete User specific Queues automatically
I hope someone can help me with this issue.我希望有人能帮助我解决这个问题。 I am using the Websocket support of Spring with SockJs and StompJs.
我正在将 Spring 的 Websocket 支持与 SockJs 和 StompJs 一起使用。 I subscribed to a queue like this:
我订阅了这样的队列:
var socket = new SockJS(localhost + 'websocket');
stompClient = Stomp.over(socket);
stompClient.connect('', '', function(frame) {
stompClient.subscribe("/user/queue/gotMessage", function(message) {
gotMessage((JSON.parse(message.body)));
});
}, function(error) {
});
This works really fine with the SimpMessageSendingOperations of Spring.这对于 Spring 的 SimpMessageSendingOperations 非常有效。 BUT there is one big problem.
但是有一个大问题。 The Queue name looks like this: gotMessage-user3w4tstcj and it's not declared as an auto delete queue, but this is what I want.
队列名称如下所示: gotMessage-user3w4tstcj并且它没有声明为自动删除队列,但这正是我想要的。 Otherwise, I have 10k unused queues.
否则,我有 10k 个未使用的队列。 In that moment where the queue has no consumer, the queue should be deleted.
在队列没有消费者的那一刻,应该删除队列。 How can I assume this?
我怎么能假设这个?
had same problem, from the documentation:有同样的问题,来自文档:
RabbitMQ creates auto-delete queues when destinations like /exchange/amq.direct/position-updates are used.
当使用像 /exchange/amq.direct/position-updates 这样的目的地时,RabbitMQ 会创建自动删除队列。 So in that case the client could subscribe to /user/exchange/amq.direct/position-updates
所以在这种情况下,客户端可以订阅 /user/exchange/amq.direct/position-updates
remember to add ' /exchange/
' as a destination prefix in stomp broker relay configuration记得在 stomp broker 中继配置中添加“
/exchange/
”作为目标前缀
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.