In my ActiveMQ client when I specify which broker to which to connect, what's the difference between specifying
tcp://host:port
and
failover:(tcp://host:port)
I've tried stopping and starting the broker and in both cases the client finds the broker again when it restarts. I haven't experimented with messages in flow (I'm using queues) or other network failures yet to see if there is a difference.
Hopefully someone has a definitive answer as the documentation I've found is a bit vague.
Thanks
The Failover transport randomly chooses one of the composite URIs and attempts to establish a connection to it. If it does not succeed, or if it subsequently fails, a new connection is established choosing one of the other URIs randomly from the list.
The VM transport allows clients to connect to each other inside the VM without the overhead of the network communication. The connection used is not that of a socket connection but instead uses direct method invocations to enable a high performance embedded messaging system.
The Broker URI allows you to run a configured broker using a single URI for all the configuration.
ActiveMQ implements a RESTful API to messaging which allows any web capable device to publish or consume messages using a regular HTTP POST or GET.
If you use failover, then the client library go into a reconnect loop when you loose connection to the server. The network failure will be hidden from your app. If you don't use failover, then when you loose your connection then your app will get a JMS error telling you you lost the connection.
failover protocol also lets you provide some useful connection parameters. For ex:
failover:(tcp://host:port)?jms.useAsyncSend=true&timeout=5000
Here timeout=5000
will make sure to bail out initial connection attempt after 5 sec if broker isn't available or not responding.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With