Search code examples
rabbitmqstomp

stomp.js creating rabbitMQ queue without routing key


I am using RabbitMQ for pub-sub. I have an exchange of type topic, I am subscribing to the exchange using stomp.js

var ws = new SockJS('http://127.0.0.1:15674/stomp')
var client = Stomp.over(ws) 
client.subscribe('/exchange/foo', function() {...})

But the problem with a subscription is for every new host, a separate queue is created with a name with a prefix stomp-subscription- and an empty routing key. I want to set the routing key as #.

Please advise if something is wrong with the above approach.


Solution

  • I suggest reading this document as it looks as though you're not using the correct URL. The docs say the path is /ws, not /stomp.

    To subscribe to a routing key, you must change your code to /exchange/foo/PATTERN where PATTERN is the pattern matching the routing key. This is documented in the STOMP plugin docs.