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,自动删除用
基础教程推荐
- 多个组件的复杂布局 2022-01-01
- 如何在 Spring @Value 注解中正确指定默认值? 2022-01-01
- 如何在 JFrame 中覆盖 windowsClosing 事件 2022-01-01
- 大摇大摆的枚举 2022-01-01
- 从 python 访问 JVM 2022-01-01
- 不推荐使用 Api 注释的描述 2022-01-01
- 在 Java 中创建日期的正确方法是什么? 2022-01-01
- Java 实例变量在两个语句中声明和初始化 2022-01-01
- 验证是否调用了所有 getter 方法 2022-01-01
- Java Swing计时器未清除 2022-01-01
