問題描述
我希望有人可以幫助我解決這個問題.我正在使用帶有 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,自動刪除用戶特定隊列的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!