Mobility
Mobility

Reputation: 3305

Activemq topic load balance without virtual destinations?

Let's say I have 3 subscribers A,B,C for one topic, and I want A,B to be treated "same subscriber", meaning they can get only one copy of each message. And C got another copy.

I find that http://activemq.apache.org/virtual-destinations.html is one way. But what if I can't change the activemq broker's config?

I wonder if there is some "id" props, can make two subscribers to be treated as one? like group id in kafka?

Upvotes: 1

Views: 424

Answers (1)

Petter Nordlander
Petter Nordlander

Reputation: 22279

I presume you are using JMS from your client. ActiveMQ 5.x only support JMS 1.1 which does not allow load balanced topics. JMS 2.0 does and is implemented in ActiveMQ Artemis, but that's another product.

However, you can use Virtual Topics without config changes, but you have to change your naming of topics and queues.

Publish to topic: VirtualTopic.[TopicName] and consume from queues: Consumer.[LogicalConsumerId].VirtualTopic.[TopicName].

I.e.

Publish orders to VirtualTopic.Orders

Consume from:

  • Consumer.ManufacturingSystem.VirtualTopic.Orders
  • Consumer.CRMSystem.VirtualTopic.Orders

etc.

As the consumers consume from a queue, they can use different (or no) ClientId and still have a load balancing among nodes in each system. I.e. the CRMSystem may have two nodes and will only receive one message in total.

This naming convention can be customized if you change ActiveMQ config, but works OOTB.

Upvotes: 6

Related Questions