[MRG M] How do I specify the qpid connection string in a clustered environment?

Solution Unverified - Updated -

Environment

  • Red Hat MRG Messaging in clustered environment

Issue

  • How do I specify the qpid connection string in a clustered environment?

Resolution

  • To use more than one connection address, you should be able to do it by putting them together in the first arg to the connection. When you do this, you need to put "amqp:" in front of the first address, then separate all other addresses by a comma ",".
    Here is the original documented code:

      #include <qpid/messaging/FailoverUpdates.h>
      ...
      Connection connection("qpidserver1:5672");
      connection.setOption("reconnect", true);
      try {
          connection.open();
          std::auto_ptr<FailoverUpdates> updates(new FailoverUpdates(connection));
    
  • Assuming a second clustered broker at qpidserver2:5672, the line:

      Connection connection("qpidserver1:5672");
    

turns into

  Connection connection("amqp:qpidserver1:5672,qpidserver2:5672");
  • In this case, if qpidserver1:5672 cannot connect, qpidserver2:5672 will be tried.  Once you are connected, you can then declare the FailoverUpdates as shown, and that mechanism will take care of failovers from then on.  With the FailoverUpdates feature, you do not need to know what the other cluster node addresses are, since the client library should take care of failing you over if necessary. (The library maintains a list of the other members of the cluster without you having to do anything.)

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.

Comments