Websockets, SockJs, Stomp, Spring, RabbitMQ, delete User specific Queues automatically(Websockets、SockJs、Stomp、Spring、RabbitMQ,自动删除用户特定队列)
问题描述
我希望有人可以帮助我解决这个问题.我正在使用带有 SockJs 和 StompJs 的 Spring 的 Websocket 支持.我订阅了这样的队列:
I hope someone can help me with this issue. I am using the Websocket support of Spring with SockJs and 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) {
});
这对 Spring 的 SimpMessageSendingOperations 非常有效.但是有一个大问题.队列名称如下所示: gotMessage-user3w4tstcj 并且没有声明为自动删除队列,但这正是我想要的.否则,我有 10k 个未使用的队列.在队列没有消费者的那一刻,应该删除队列.我怎么能假设这个?
This works really fine with the SimpMessageSendingOperations of Spring. 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. Otherwise, I have 10k unused queues. 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 在目的地像使用/exchange/amq.direct/position-updates.所以在那种情况下客户端可以订阅/user/exchange/amq.direct/position-updates
RabbitMQ creates auto-delete queues when destinations like /exchange/amq.direct/position-updates are used. So in that case the client could subscribe to /user/exchange/amq.direct/position-updates
记得在 stomp 代理中继配置中添加/exchange/
"作为目标前缀
remember to add '/exchange/
' as a destination prefix in stomp broker relay configuration
这篇关于Websockets、SockJs、Stomp、Spring、RabbitMQ,自动删除用户特定队列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Websockets、SockJs、Stomp、Spring、RabbitMQ,自动删除用


- 如何指定 CORS 的响应标头? 2022-01-01
- 将 Java Swing 桌面应用程序国际化的最佳实践是什么? 2022-01-01
- 如何使 JFrame 背景和 JPanel 透明且仅显示图像 2022-01-01
- 在 Java 中,如何将 String 转换为 char 或将 char 转换 2022-01-01
- Eclipse 的最佳 XML 编辑器 2022-01-01
- 转换 ldap 日期 2022-01-01
- 获取数字的最后一位 2022-01-01
- GC_FOR_ALLOC 是否更“严重"?在调查内存使用情况时? 2022-01-01
- 未找到/usr/local/lib 中的库 2022-01-01
- java.lang.IllegalStateException:Bean 名称“类别"的 BindingResult 和普通目标对象都不能用作请求属性 2022-01-01