5 Replies Latest reply on Oct 23, 2017 3:47 AM by mnovak

    How to connect to a cluster of Artemis MQ servers?

    mylos78

      Hi all,

      from the documentation of WildFly 10 it is shown how to connect to a remote ArtemisMQ server:

      Connect a pooled-connection-factory to a Remote Artemis Server - WildFly 10 - Project Documentation Editor

      However what will be if we need to connect to a cluster of servers? The remote-destination-socket-binding allows just a single host/port address:

      /socket-binding-group=standard-sockets/remote-destination-outbound-socket-binding=remote-artemis:add(host=<server host>, port=61616)

       

      Any idea ?
      Thanks
        • 1. Re: How to connect to a cluster of Artemis MQ servers?
          mnovak

          Hi Mylos,

           

          pooled-connection-factory is load-balancing connections by default. Connector(s) which you're specifying in configuration are used for initial connection. Then cluster topology is loaded and 2nd connection usually points to another server in cluster. Default load-balancing policy is round-robin.

           

          Cheers,

          Mirek

          • 2. Re: How to connect to a cluster of Artemis MQ servers?
            milanr

            Hi Miroslav,

             

            what if we don't know which server is live at the moment of clients first connection and initial connection failed? In that case clients won't be able to load cluster topology.

            Can we use discovery group address? On the other project I'm using hornetq cluster and clients from JBoss connects to cluster via resource adapter. All configuration is in ra.xml, we can define DiscoveryAddress and DiscoveryPort and everything works fine.

            I know that things has changed in Wildfly and artemis-ra is somehow 'hidden' (the RA is constructed programmatically by the messaging system). Is there option to configure activemq RA in Wildfly? To configure discovery address and port

             

            Thanks

            Milan

            • 3. Re: How to connect to a cluster of Artemis MQ servers?
              mnovak

              Hi Milan,

               

              yes, discovery group will solve the problem with identification of live and backup servers and will load-balance connections to live.

               

              You're right that configuration of Artemis RA has changed. Currently Artemis RA is configured in messaging-activemq subsystem using pooled-connection-factory which configures outbound and inbound connection at the same time. You'll need to set your discovery-group in pooled-connection-factory so it' used for this purpose:

               

              ...
              <discovery-group name="dg-group1" jgroups-channel="activemq-cluster" refresh-timeout="10000"/>
              <pooled-connection-factory name="activemq-ra" ... discovery-group="dg-group1" ... />
              ...
              

               

              Thanks,

              Mirek

              • 4. Re: How to connect to a cluster of Artemis MQ servers?
                milanr

                Hi Mirek,

                Thank you for response. I've figured it out on Friday night but weekend caught me and I didn't manage to answer myself here

                Anyways, I solved it very similar with only difference I used UDP:

                 

                <discovery-group name="dg-artemis" socket-binding="artemis-discovery"/>
                <pooled-connection-factory name="activemq-ra" entries="java:/JmsXA" discovery-group="dg-artemis" ha="true"/>
                ...
                <socket-binding name="artemis-discovery" interface="messenger" multicast-address="231.0.0.9" multicast-port="9876"/>
                

                 

                In my local env I had issue with discovery cluster from WF, I received errors during startup like:

                AMQ122018: Could not start recovery discovery on XARecoveryConfig ... we will retry every recovery scan until the server is available
                

                 

                 

                .. so I had to add to interfaces:

                <interface name="messenger">
                  <any-address/>
                </interface>
                

                 

                Thanks

                Milan

                • 5. Re: How to connect to a cluster of Artemis MQ servers?
                  mnovak

                  Great that you've manged to solve it :-) and nice solution with any-address interface.

                   

                  The error:

                  AMQ122018: Could not start...
                  

                   

                  probably relates to the problem that Recovery Manager could not find interface where it should listen to multicast 231.0.0.9:9876. I'm happy to see that using

                  1.   <any-address/> 

                  is working which is basically equivalent to setting 0.0.0.0.