ActiveMQ with subscriber JMS selector

241 views Asked by At

I am trying to port a current RabbitMQ implementation over to ActiveMQ (for several reasons beyond my control). I'm trying to design the same flow of data as our current RabbitMQ design.

In our current design we create a topic in RabbitMQ, then consumers (players) create their queues and bind to the topic using a key binding ( with the format player-[id]-[up/down]). So you end up with a Topic named GamePoints and thousands of queues (one per player) binding to that topic with the key equals to the player id. We can now produce a message to the GamePoints topic with a key of player-1234-up and the player with that ID will receive the message. This is working great. This also allows us to create key bindings like player-1234-* and receive all the messages destined to that player.

I'm new to ActiveMQ and trying to mimic this behavior. So far I've come up with the following:

  • We create a topic named GamePoints
  • Each player, when it connects, will create a subscriber to the topic with a JMS Selector of playerId=1234
  • When the game produces a message it sends it to the GamePoints topic with the PlayerId header value of 1234
  • The subscriber with the JMS Selector (as long as is active at that time) will receive this message, no other subscriber will receive it
  • We can also create subscribers with selectors like playerId like '1234-%'

Is this a good pattern? I'm afraid of this not scaling because in the scenario where I have hundreds of thousands of subscribers it will have to run the JMS selector hundreds of thousands per message

Thank you for your help!

0

There are 0 answers