Search code examples
load-balancingactivemq-artemis

Load Balancing with multi broker ActiveMQ artemis instance


I need your help to suggest me how best I can achieve load balancing using the below diagram. here I am trying to create 2 machines with Master and expecting that the consumer/publisher application will use one common URL( a load-balanced one), where I should not expose the individual VM machine info and port ID. just that load balancer should take care of routing..

this is typically what we do with help of F5 load balancer or HTTP load balancer ..just wondering can be achieved over ActiveMQ and its advisable..?

on other side, I also tried configuring this way on weblogic to consume data from ActiveMQ queue failover://(tcp://localhost:61616,tcp://localhost:61617)?randomize=true but this does not help.. or WebLogic is not understanding this format.

enter image description here


Solution

  • Messaging connections are stateful. They are not stateless like HTTP connections, and therefore cannot be load-balanced in the same way as HTTP connections. It may be possible to configure an F5 to deal with stateful messaging connections, but I can't say for sure. I'm not an expert on F5.

    Both the ActiveMQ Artemis broker itself as well as the JMS client shipped with the broker have load-balancing functionality built in. There's too much to cover here so I recommend you review the clustering documentation for the relevant details.

    You might also try using the broker balancer feature. It's currently experimental, but it should be ready to use in the 2.21.0 release coming in the March/April time-frame. It can act like an F5 for your messaging connections, but it can do some more intelligent things like always sending certain clients to the same node which can facilitate certain use-cases which are not possible in a traditional cluster. (See update below)

    The URL failover://(tcp://localhost:61616,tcp://localhost:61617)?randomize=true which are you using is for the OpenWire JMS client shipped with ActiveMQ 5.x. If you're using the core JMS client shipped with ActiveMQ Artemis then you should be using a URL like this instead:

    (tcp://localhost:61616,tcp://localhost:61617)?ha=true
    

    Update on production readiness of the Broker Balancer feature:

    As of version 2.21.0, this feature has been completed and incorporated into the latest documentation pool with title Connection Routers (2.30.0 at the time of this writing).

    Above link is also updated to reflect the latest version that the feature lived in the documentation pool under title Broker Balancer (2.20.0)