High availability, failover on Rabbitmq in nodejs

rabbitmq

I want to setup high availability on rabbitmq nodes, currently i have single server running rabbitmq, however i am going to add another
Here is the current configuration we are using in nodejs application

rabbitMQ: {
  url: 'amqp://user:password@node1:5672'
},

1) Do i need to setup cluster on both rabbitmq nodes(node1 and node2)?

2) What would be the new url i have to include in config file

Best Answer

The RabbitMQ team monitors this mailing list and only sometimes answers questions on StackOverflow.


You don't provide details about what RabbitMQ version, Erlang version, operating system, or Node.js library you are using. Please in the future always provide people with details like this to make it easier for them to help out.

Since you are new to RabbitMQ clustering, so I highly recommend that you read our documentation for it - https://www.rabbitmq.com/clustering.html

Do i need to setup cluster on both rabbitmq nodes(node1 and node2)?

Both nodes must be running the same version of RabbitMQ and Erlang. You create the cluster according to the documentation by running the clustering commands on one node. If you were successful the rabbitmqctl cluster_status command will indicate so.

2) What would be the new url i have to include in config file

I am assuming that you are using the squaremo/amqp.node library. That library does not support providing multiple hosts in the connection URI. You must implement that yourself, and you would also have to implement connection recovery yourself. Please see this GitHub issue.

However, one library that does support multiple nodes and reconnection is called rascal. You can either use rascal or borrow code from it (here, for example).

Related Topic