Hi Gary,

On Tue, Mar 22, 2011 at 5:16 PM, Gary Tully [via ActiveMQ]
<ml-node+3396678-858026179-223...@n4.nabble.com> wrote:
> The test needs some mods to ensure that the slave broker listen port
> is only started when the broker becomes the baster.
>
> In code, the addition of the transportConnector needs to be:
>
>         // lazy create transport connector on start completion
>         TransportConnector connector = new TransportConnector();
>         connector.setUri(new URI("tcp://localhost:" + listenPort));
>         broker.addConnector(connector);

Ok, so I need to add a check to the broker initialization before
adding the connector. There's a waitUntilStarted method in
BrokerService, is this the one to use? A quick test with

broker.start();
broker.waitUntilStarted();
broker.addConnector("tcp://localhost:"+port);

did not make the test pass. I'm looking at the embedded broker FAQ
page and the BrokerService API documentation, but it doesn't provide
much help for this scenario.

> In cases where failover needs to abort you can configure the
> maxReconnectAttempts to be > 0 and it will fail with an exception
> after X attempts.

Yep, I tried to keep the amount of options to a minimum in the test
case. In the case I'm describing there is a broker up and running, the
failover transport just doesn't get around to connecting to it.

> On 22 March 2011 14:31, rasmusback <[hidden email]> wrote:
>> Hi,
>>
>> I'm using the shared file system, master slave setup with two brokers on
>> separate servers. My clients are configured to use the failover transport
>> with a URL like this:
>> failover://(tcp://broker1:61616,tcp://broker2:61616)?randomize=false. I've
>> noticed that the order of the brokers in the failover URL seems to be
>> significant. If I start broker2 before broker1, so that broker2 becomes
>> the
>> master and broker1 the slave, clients will get stuck in a reconnect loop
>> where they keep trying to connect to broker1.
>>
>> Attached is a junit test case which exhibits the same behavior as my
>> setup.
>> If the startup order of the brokers is different from their order in the
>> failover URL, the test will timeout. When the order is the same, the test
>> will pass.
>>
>> The slave broker opens a socket, so a tcp connection is possible to it
>> even
>> though the broker functionality isn't enabled. This might be what is
>> confusing the failover transport.
>>
>> I'm not quite sure if my broker configuration is incorrect or if this is a
>> bug (or feature) in a master slave setup, so any help is much appreciated.
>> I'm using ActiveMQ 5.4.2 and spring-jms 2.5.5.
>>
>>   Rasmus
>>
>> http://activemq.2283324.n4.nabble.com/file/n3396540/FailoverTest.java
>> FailoverTest.java
>>
>> --
>> View this message in context:
>> http://activemq.2283324.n4.nabble.com/Clients-can-get-stuck-in-a-reconnect-loop-with-master-slave-brokers-tp3396540p3396540.html
>> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>>
>
>
> --
> http://blog.garytully.com
> http://fusesource.com
>
>
> ________________________________
> If you reply to this email, your message will be added to the discussion
> below:
> http://activemq.2283324.n4.nabble.com/Clients-can-get-stuck-in-a-reconnect-loop-with-master-slave-brokers-tp3396540p3396678.html
> To unsubscribe from Clients can get stuck in a reconnect loop with
> master-slave brokers, click here.


--
View this message in context: 
http://activemq.2283324.n4.nabble.com/Clients-can-get-stuck-in-a-reconnect-loop-with-master-slave-brokers-tp3396540p3398869.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Reply via email to