2
votes

I understand the topic is for broadcasting messages to the clients. But in the ActiveMQ document, it says about load balancing:

Another way of explaining Message Groups is that it provides sticky load balancing of messages across consumers; where the JMSXGroupID is kinda like a HTTP session ID or cookie value and the message broker is acting like a HTTP load balancer.

Here comes what I don't understand.

Is it not broadcasting?

What I want to do is below: If producer send messages to group A, somehow the broker control the traffic and the messages "physically" should not go to group B.

Is it even possible with Virtual Topic?

1

1 Answers

3
votes

VirtualTopics create queues for each topic subscriber and replicates messages to each one, so it is "broadcasting" all messages to all subscribers.

ActiveMQ message groups provide you with an exclusive consumer thread for a given message group (distinct JMSXGroupID). You can't control which consumer picks up each group and the same consumer thread can process multiple groups.

As far as I know, if you set the JMSXGroupID on a message sent to a VirtualTopic, it will arrive in each subscriber's virtual queue. However, if you have multiple threads processing from those queues (maxConcurrentConsumers > 1), then they will be single-threaded per message group, etc.

Overall, if you want certain subscribers to only process a subset of messages sent to a topic, then use message selectors to down select this subset.