node-amqp icon indicating copy to clipboard operation
node-amqp copied to clipboard

Handle failover in amqp

Open agollahareesh opened this issue 13 years ago • 9 comments

Is there any way to connect two rabbitmq servers while connecting from node. In present version 0.1.3 it is only supporting single connection to rabbitmq server. Actually the rabbitmq is running in clustered environment, if one connection is failed iam unable to connect other rabbitmq node.
I tried by adding close listener to handle the fail condition and it worked fine for first connect and for second connect the socket is closing.

agollahareesh avatar Jun 21 '12 02:06 agollahareesh

Multiple connections would be a nice feature.

anthonyu avatar Jun 17 '13 23:06 anthonyu

This does work if you pass in an array of hostnames for the addresses. You can also use hostPreference inside your config as well to specify preference for a specific host

chriswiggins avatar Jun 25 '13 11:06 chriswiggins

It will be highly appreciated if an example of how to supply an array of hostnames, since I couldn't find an example or an explanation in the docs.

momico avatar Jun 08 '14 11:06 momico

:+1:

vertex avatar Jan 09 '15 16:01 vertex

Hi

Am using amqplib/callback_api. how can i list all the rabbit nodes in the connection url.

PreethiBabu87 avatar Jul 10 '15 12:07 PreethiBabu87

Unfortunately as far as I'm aware you can't. We'd all be grateful for a pull request though! :-)

Sent from my iPhone

On 11/07/2015, at 12:33 am, PreethiBabu87 <[email protected]mailto:[email protected]> wrote:

Hi

Am using amqplib/callback_api. how can i list all the rabbit nodes in the connection url.

Reply to this email directly or view it on GitHubhttps://github.com/postwait/node-amqp/issues/107#issuecomment-120399671.

chriswiggins avatar Jul 10 '15 20:07 chriswiggins

So how will I be able to perform multiple connections using nodejs other than amqplib/callback_api? Any other package can be used?

PreethiBabu87 avatar Jul 12 '15 15:07 PreethiBabu87

And I see your comment above stating that array of host names work.. What's the npm package that's required in order to get it work

PreethiBabu87 avatar Jul 12 '15 16:07 PreethiBabu87

@PreethiBabu87 its this package. Just don't use URLs to connect, do what is suggested at the top of the README:

var connection = amqp.createConnection({ host: 'dev.rabbitmq.com' });

However for multiple hosts, do:

var connection = amqp.createConnection({ hostArray:
[ 'dev.rabbitmq.com', 'host2', 'host3'] });

chriswiggins avatar Jul 12 '15 20:07 chriswiggins