Print
How to auto reconnnect if the JMS broker is down

If a JMS broker goes down your JMS connection fails and so does your Lingo remoting layer. So its useful to be able to avoid this issue, so that your application keeps running irrespective of whether the JMS broker you are connected to is taken down (or a network error causes it to be temporarily inaccessible).

You have two options.

  • run an embedded broker so that there is always an ActiveMQ broker to connect to in your JVM
  • use auto-reconnect with ActiveMQ so that it will keep retrying to connect until a broker starts.

in particular on 4.x you can configure the failover reconnection policy so you can configure the ActiveMQ client to reconnect forever by setting the brokerURL property on the ActiveMQConnectionFactory to something like

failover:(tcp://host:port)?maxReconnectAttempts=0

Where host and port are the actual host and port to use. Note inside the () you can specify a list of URLs to connect to; one will be randomly chosen

Powered by Atlassian Confluence