Question

Let's say I have the following ActiveMQ connection string:

failover:(tcp://broker1:61616,tcp://broker2:61616)?randomize=true

I am sending in like a few thousands requests to the brokers from a Java producer which has this configuration.

Sometimes I noticed that all messages end up going to just 1 broker with the other not receiving a single message.

Is this normal behavior?

Out of 10 tests, I made I may have noticed this behavior a couple of times. And at other times both the brokers received the message.

How randomize=true works?

The only explanation I found on http://activemq.apache.org/failover-transport-reference.html is: "use a random algorithm to choose the the URI to use for reconnect from the list provided"

Was it helpful?

Solution

The randomize flag on the failover transport indicates that the transport should choose at random one of the configured broker URIs to connect to (in your case there are two to choose from. Once a client is connect to one of those brokers the client will remain happily connected and send messages only to that broker until such time as something happens to interrupt the connection. Once the connection is interrupted the client will again attempt to connect to one of those two brokers. So in your case the single producer sending all its messages to one broker means, its working just like its expected too.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top