Sending over failover transport with timeout

The failover transport proved to be useful for many use cases, but had one drawback. When no browsers are available, your send operation will hang. One of the ways to deal with this is to use TransportListener to detect and handle those cases.

From 5.3 version onwards, you will be able to use new timeout option on the protocol that should solve this problem naturally. So, if you use an URL like this:

failover:(tcp://primary:61616)?timeout=3000

your send will throw an exception like this one:

javax.jms.JMSException: Failover timeout of 3000 ms reached.

if the connection isn’t established. The connection is not killed and the reconnection procedure will not be interrupted, so you can use it as you’d normally do (and hopefully your broker will come on-line soon 🙂

2 comments

Comments are closed.