mpmp
mpmp

Reputation: 2459

ActiveMQ FailoverTransport reconnecting too fast on Linux compared to Windows

I have one ActiveMQ broker on my Linux machine and a standalone Java application that acts as a producer running on my Windows machine. Both Windows and Linux machines are using the same version of Java 7.

I specify my broker url to be:

failover://(tcp://10.0.112.49:61616)?timeout=1000&warnAfterReconnectAttempts=1&maxReconnectAttempts=0`

Windows scenario: I start my application and it automatically connects to the ActiveMQ broker. When I stop the broker, the FailoverTransport tries to reconnect every second.

2015-07-16 15:14:52,737 ERROR [ActiveMQ Task-1] (FailoverTransport.java:1099) CSN: Failed to connect to [tcp://10.0.112.49:61616] after: 1 attempt(s)

This is the expected behavior.

However, when I run the application on Linux, instead of trying to reconnect every second, it reconnects every 5-10 milliseconds! I was wondering why the behavior is different.

Upvotes: 0

Views: 660

Answers (1)

Nikolay K
Nikolay K

Reputation: 3850

Your problem is that you don't understand timeout option. Here is what documentation says

timeout

Enables timeout on send operations (in miliseconds) without interruption of reconnection process

However in Configuring ActiveMQ-CPP I think it described better (but still the same).

timeout

If a send is blocked waiting on a failed connection to reconnect how long should it wait before failing the send, default is forever (-1).

If I have understand you, the options you want is initialReconnectDelay, maxReconnectDelay and useExponentialBackOff.

See also:

  1. How do I configure automatic reconnection
  2. How can I support auto reconnection
  3. using activemq failover URI for reconnecting, while timeout on first connection

Upvotes: 1

Related Questions