Search code examples
node.jsamqprhea

Failover for NodeJS rhea AMQP client


I want to implement the failover mechanism in my NodeJS rhea code similar to what Spring Boot does with JMS.

I am using an AMQP connection in NodeJS use rhea in the following way:

var container = require('rhea');
container.on('message', function (context) {
    console.log(context.message.body);
    context.connection.close();
});
container.once('sendable', function (context) {
    context.sender.send({body:'Hello World!'});
});
var connection = container.connect({'port':5672});
connection.open_receiver('examples');
connection.open_sender('examples');

I want to provide multiple connections at container.connect(multipleconnections) from which it will pick available connections instead of just container.connect({'port':5672}).


Solution

  • You have to do some work to build your client code such that reconnect happens, rhea doesn't have the sort of failover processing support that clients like Qpid JMS or the Artemis Core JMS client do.

    There is a reconnect example in the Rhea source tree that you can use as a starting point to build that logic into your own application.