問(wèn)題描述
我希望有人可以幫助我解決這個(gè)問(wèn)題.我正在使用帶有 SockJs 和 StompJs 的 Spring 的 Websocket 支持.我訂閱了這樣的隊(duì)列:
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) {
});
這對(duì) Spring 的 SimpMessageSendingOperations 非常有效.但是有一個(gè)大問(wèn)題.隊(duì)列名稱如下所示: gotMessage-user3w4tstcj 并且沒(méi)有聲明為自動(dòng)刪除隊(duì)列,但這正是我想要的.否則,我有 10k 個(gè)未使用的隊(duì)列.在隊(duì)列沒(méi)有消費(fèi)者的那一刻,應(yīng)該刪除隊(duì)列.我怎么能假設(shè)這個(gè)?
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?
推薦答案
有同樣的問(wèn)題,來(lái)自文檔:
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/
"作為目標(biāo)前綴
remember to add '/exchange/
' as a destination prefix in stomp broker relay configuration
這篇關(guān)于Websockets、SockJs、Stomp、Spring、RabbitMQ,自動(dòng)刪除用戶特定隊(duì)列的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!