Search code examples
jmsselectoractivemq-classicstomp

Stomp selector condition


I'm registering a web client via Stomp to an ActiveMQ messaging server. The clients have a username and register to a common topic by setting a selector.

var headers = {'selector': "to = '" + userName + "'"};

A client sends a message by setting a 'to' attribute in the header. Is it possible to also receive broadcast messages with a more complex selector? I'm looking for something like

var headers = {'selector': "to = '" + self.userName + "' OR *"};

to receive messages destined for all users.


Solution

  • Never mind the question. I found a solution. It's actually pretty much as I already guessed (I really should have tried it before posting). There's also a ActiveMQ document on that: http://activemq.apache.org/selectors.html

    The correct syntax is

    var headers = {'selector': "to = '" + self.userName + "' OR '*'"};