Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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. 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. 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?

like image 957
Ogniute Avatar asked Sep 30 '22 05:09

Ogniute


1 Answers

had same problem, from the documentation:

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

remember to add '/exchange/' as a destination prefix in stomp broker relay configuration

like image 138
Yoav A Avatar answered Oct 06 '22 00:10

Yoav A