What is the best connection URI for ActiveMQ if I want to Fail Fast?
I'm using ActiveMQ in Java to log incoming analytics beacons. Ideally if the queue goes down or gets locked up I'd like to fail as fast as possible, log the beacon locally then return to the client without hanging, then try to reconnect later.
What is the best connection开发者_StackOverflow中文版 URI and URI parameters for that use case when using ActiveMQ?
I would suggest using AMQ's failover transport for your case. eg: try this form of URL (available in AMQ ver 5.3 onwards):
failover:(tcp://jms.host1:61616,tcp://jms.host2:61616,tcp://jms.host3:61616)?timeout=5000
This just means that try to connect JMS brokers running on jms.host1, jms.host2, jms.host3 for 5 sec and return an error to client if no connection is available. It will also take care of automatic failover to connect to jms.host1 or jms.host3 if your client looses connection to jms.host2.
Look at this page for documentation on failover transport: http://activemq.apache.org/failover-transport-reference.html
精彩评论