The messaging broker can be run in clustering mode, which provides high reliability through replicating state between brokers in the cluster. If one broker in a cluster fails, clients can choose another broker in the cluster and continue their work. Each broker in the cluster also advertises the addresses of all known brokers [11] . A client can use this information to dynamically keep the list of reconnection urls up to date.
In C++, the FailoverUpdates class provides this functionality:
Example 1.19. Tracking cluster membership
In C++:
#include <qpid/messaging/FailoverUpdates.h>
...
Connection connection("localhost:5672");
connection.setOption("reconnect", true);
try {
connection.open();
std::auto_ptr<FailoverUpdates> updates(new FailoverUpdates(connection));
In python:
import qpid.messaging.util
...
connection = Connection("localhost:5672")
connection.reconnect = True
try:
connection.open()
auto_fetch_reconnect_urls(connection)
In .NET C#:
using Org.Apache.Qpid.Messaging;
...
connection = new Connection("localhost:5672");
connection.SetOption("reconnect", true);
try {
connection.Open();
FailoverUpdates failover = new FailoverUpdates(connection);
Apache Qpid, Messaging built on AMQP; Copyright © 2015 The Apache Software Foundation; Licensed under the Apache License, Version 2.0; Apache Qpid, Qpid, Qpid Proton, Proton, Apache, the Apache feather logo, and the Apache Qpid project logo are trademarks of The Apache Software Foundation; All other marks mentioned may be trademarks or registered trademarks of their respective owners