0
votes

I've two question for ActiveMQ failover protocol.

Question 1: When I use following url with nested it doesn't connect to ActiveMQ.

failover:(tcp://192.168.1.111:61616)?nested.jms.useAsyncSend=true&initialReconnectDelay=1000&maxReconnectAttempts=-1

Question 2: Following url works fine. It also reconnect to ActiveMQ on first restart but when I shutdown ActiveMQ for second time Java program terminates and there ain't any exception.

failover:(tcp://192.168.1.111:61616)?jms.useAsyncSend=true&initialReconnectDelay=1000&maxReconnectAttempts=-1

ActiveMQ Version: 5.10.0

Reference: http://activemq.apache.org/failover-transport-reference.html

1

1 Answers

0
votes

The nested prefix is only useful for options that apply to the inner TCP / SSL transports inside the failover URI, or possibly to broker addresses that are discovered using multicast discovery etc. They do not apply to the connection level options (those starting with 'jms.' for instance). Your first URI would be correct if set to the following:

failover:(tcp://192.168.1.111:61616)?jms.useAsyncSend=true&initialReconnectDelay=1000

This is because the jms.useAsyncSend option applies the the whole connection, not to a single connection to the given tcp based transport inside the failover URI.

Nested options would be things like soTimeout or tcpNoDelay etc.

You do not need to try and set reconnect attempts to infinite because that was and still is the default assumption, only when you want to limit it to some fixed number of attempts do you need to set this option.

If your application is shutting down during failover reconnection cycles then my guess is that you are relying on the ActiveMQ library to maintain at least one non-daemon thread to keep it alive which is really a poor assumption, relying on any third party to keep your application running is generally bad practice and you should make your own design enforce that the application stay up until you really want it to shut down.