-1

I am trying to use Apache Camel and the Qpid JMS client to connect to an ActiveMQ Artemis active-active cluster running in two different nodes (VM's). I'm using ActiveMQ Artemis 2.17.0.

Broker1 --- Host1:5672 (active)
Broker2 --- Host2:5672 (active)

I'm trying to figure out what should be the remoteURI configuration for my org.apache.qpid.jms.JmsConnectionFactory instance. Using ampq://host1:5672,ampq://host2:5672 didn't work. I haven't seen any reference in the documentation.

I want the producer to push messages to both the brokers either by Round-robin or default way, and I want the consumer to consume those message from both brokers either in load balanced way.

For master-backup configuration the below worked:

<bean id="jmsampqConnectionFactory" class="org.apache.qpid.jms.JmsConnectionFactory">
   <property name="remoteURI" value="failover:(ampq://host1:5672,ampq://host2:5672)" />
   <property name="username" value="user"/>
   <property name="password" value="pass"/>
</bean>

For a master-slave configuration this worked. So when the master is active the client sent messages to master, when master is down the client pushed messages to slave. We didn't had any issues there. However, for active-active this won't work. What URL should I use?

For reference, broker configuration is the same as in my previous Stack Overflow question.

Justin Bertram
  • 29,372
  • 4
  • 21
  • 43
Tim
  • 1,321
  • 1
  • 22
  • 47
  • What exact behavior are you looking for? You don't actually describe this in your question. Do you want, for example, the client to connect to the first available broker in the list which you supply? Something else? Please clarify. Thanks! – Justin Bertram Feb 21 '22 at 18:16
  • Can you also clarify exactly why using `failover:(ampq://host1:5672,ampq://host2:5672)` doesn't work? – Justin Bertram Feb 21 '22 at 18:23
  • Looking for producer to push message to both the broker, and consumer client to consume message from both the broker queue. Added my inputs at the bottom of the question. Thanks. – Tim Feb 21 '22 at 18:43
  • In order for the client to send messages to the brokers in a round-robin fashion it would either have to create a connection to *every* broker in the list and rotate the connection for every message it sent or it would have to create a close a connection to a different broker in the list every time it sent a message. Either one of these approaches is wildly inefficient. I don't know of any JMS client in the industry that has such a feature. Instead, you should configure the *broker* to load-balance messages appropriately rather than asking the client to do this. The same goes for the consumer. – Justin Bertram Feb 21 '22 at 18:52
  • ok. i get that in order to send message by a Producer we need to create separate client to connect to broker's queue/topic. When consuming is there any possibility to apply client side load balancing using `amqp` scheme, similar to below, just changing tcp to amqp? – Tim Feb 21 '22 at 19:37
  • 1
    The JMS client shipped with ActiveMQ Artemis has a [*connection* load-balancing feature](https://activemq.apache.org/components/artemis/documentation/latest/clusters.html#client-side-load-balancing) whereby each connection created from the _same_ `javax.jms.ConnectionFactory` instance is made to one of the brokers listed in the URL. The default "policy" is round-robin. As far as I can tell this is not what your question is asking about. Your question appears to be asking about *message* load-balancing instead. – Justin Bertram Feb 21 '22 at 21:20

1 Answers1

0

The Qpid JMS client does not currently have (nor will it ever have) a fan-out or fan-in style connection handler to automatically handle this case as described. The client creates a single connection to a broker and will; if using failover, reconnect to another provided broker URI which is why the primary / secondary configuration you described worked but the active / active one doesn't.

You could probably solve this in other ways such as camel routes that probably could manage to do something along these lines or you could create you own JMS layer that creates a fan-out and fan-in style connection proxy. How you'd accomplish this is outside the scope of the question though.

Tim Bish
  • 17,475
  • 4
  • 32
  • 42