You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by nelsoncc <ne...@novabase.pt> on 2015/01/22 15:35:29 UTC

maxReconnectAttempts parameter

Hi, 

I'm trying to use the "maxReconnectAttempts" parameter, but without success.

I'm using a client connection with the following URI:
failover:(tcp://localhost:61616,tcp://localhost:61626)?randomize=false&useExponentialBackOff=false&initialReconnectDelay=1000&startupMaxReconnectAttempts=40&maxReconnectAttempts=1

But when I shutdown the broker, and that Client tries to send a message it
reports the error:
"ActiveMQSessionKernel - Session Already Closed"

After I start the broker again, it stills throw the same error.
If I remove the maxReconnectAttempts, the client automatically reconnects
and the message is successfully sent.

What I need is that the client tries to reconnect, if it fails throw the
error.

Does anyone what configuration should I use? 

Kind Regards, 
Nelson Cintra.

 



--
View this message in context: http://activemq.2283324.n4.nabble.com/maxReconnectAttempts-parameter-tp4690272.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Re: maxReconnectAttempts parameter

Posted by artnaseef <ar...@artnaseef.com>.
Alternatively, if the failover transports retry logic is not adequate, it may
be worth considering to move that logic up into the application.

The failover transport is awesome, but it cannot foresee every possible
application concern.

Adding reconnects and recovery at the application level is not that
complicated, if the code is structured well to support it and the recovery
paths are clearly defined.

So, the failover transport options are not the only possible solution, but
perhaps the easiest/shortest path to victory.



--
View this message in context: http://activemq.2283324.n4.nabble.com/maxReconnectAttempts-parameter-tp4690272p4690564.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Re: maxReconnectAttempts parameter

Posted by Timothy Bish <ta...@gmail.com>.
On 01/22/2015 11:00 AM, nelsoncc wrote:
> Hi,
>
> If I use the URI:
> failover:(tcp://localhost:61616,tcp://localhost:61626)?randomize=false
>
> The thread blocks in sending message, and only unlocks when broker is
> started.
> Since I don't want to block the thread I can fix my problem using timeout
> parameter.
>
> I thought the reconnect attempt was made in sendMessage and not in
> background thread, that's the reason I was trying to use the
> maxReconnectAttempts parameter.
>
> Can you confirm if the the timeout parameter is my only solution?
>
> Kind Regards,
> Nelson
>
>
>
>
>
> --
> View this message in context: http://activemq.2283324.n4.nabble.com/maxReconnectAttempts-parameter-tp4690272p4690288.html
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>
Yes, you need to use timeout to cause send to return.

-- 
Tim Bish
Sr Software Engineer | RedHat Inc.
tim.bish@redhat.com | www.redhat.com
skype: tabish121 | twitter: @tabish121
blog: http://timbish.blogspot.com/


Re: maxReconnectAttempts parameter

Posted by nelsoncc <ne...@novabase.pt>.
Hi,

If I use the URI:
failover:(tcp://localhost:61616,tcp://localhost:61626)?randomize=false

The thread blocks in sending message, and only unlocks when broker is
started.
Since I don't want to block the thread I can fix my problem using timeout
parameter.

I thought the reconnect attempt was made in sendMessage and not in
background thread, that's the reason I was trying to use the
maxReconnectAttempts parameter.

Can you confirm if the the timeout parameter is my only solution?

Kind Regards,
Nelson





--
View this message in context: http://activemq.2283324.n4.nabble.com/maxReconnectAttempts-parameter-tp4690272p4690288.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Re: maxReconnectAttempts parameter

Posted by Timothy Bish <ta...@gmail.com>.
On 01/22/2015 10:14 AM, nelsoncc wrote:
> That parameter is what I'm using, but it ignores the parameter and never
> reconnects again.
>
> Kind Regards
>
>
>
> --
> View this message in context: http://activemq.2283324.n4.nabble.com/maxReconnectAttempts-parameter-tp4690272p4690283.html
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>
The failover transport does its reconnect work in a background thread so 
it did try once and gave up it's just that it happens so fast that you 
hadn't restarted the broker yet.  In general a maxReconnectAttempts 
value of one only makes sense in the case where you want to select from 
a list of two brokers in the failover URI and then stop (randomize 
should be off).

To be clear, the reconnect attempts do not take place on the send call, 
they are async.

-- 
Tim Bish
Sr Software Engineer | RedHat Inc.
tim.bish@redhat.com | www.redhat.com
skype: tabish121 | twitter: @tabish121
blog: http://timbish.blogspot.com/


Re: maxReconnectAttempts parameter

Posted by nelsoncc <ne...@novabase.pt>.
That parameter is what I'm using, but it ignores the parameter and never
reconnects again.

Kind Regards



--
View this message in context: http://activemq.2283324.n4.nabble.com/maxReconnectAttempts-parameter-tp4690272p4690283.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Re: maxReconnectAttempts parameter

Posted by Timothy Bish <ta...@gmail.com>.
On 01/22/2015 10:04 AM, nelsoncc wrote:
> Tks for your quick feedback. So what configuration should I use in the client
> so it tries to reconnect always once, even if the broker is down?
>
> Kind Regards,
> Nelson Cintra
>
>
>
> --
> View this message in context: http://activemq.2283324.n4.nabble.com/maxReconnectAttempts-parameter-tp4690272p4690281.html
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>
maxReconnectAttempts=1

-- 
Tim Bish
Sr Software Engineer | RedHat Inc.
tim.bish@redhat.com | www.redhat.com
skype: tabish121 | twitter: @tabish121
blog: http://timbish.blogspot.com/


Re: maxReconnectAttempts parameter

Posted by nelsoncc <ne...@novabase.pt>.
Tks for your quick feedback. So what configuration should I use in the client
so it tries to reconnect always once, even if the broker is down?

Kind Regards,
Nelson Cintra



--
View this message in context: http://activemq.2283324.n4.nabble.com/maxReconnectAttempts-parameter-tp4690272p4690281.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Re: maxReconnectAttempts parameter

Posted by Timothy Bish <ta...@gmail.com>.
On 01/22/2015 09:35 AM, nelsoncc wrote:
> Hi,
>
> I'm trying to use the "maxReconnectAttempts" parameter, but without success.
>
> I'm using a client connection with the following URI:
> failover:(tcp://localhost:61616,tcp://localhost:61626)?randomize=false&useExponentialBackOff=false&initialReconnectDelay=1000&startupMaxReconnectAttempts=40&maxReconnectAttempts=1
>
> But when I shutdown the broker, and that Client tries to send a message it
> reports the error:
> "ActiveMQSessionKernel - Session Already Closed"
>
> After I start the broker again, it stills throw the same error.
> If I remove the maxReconnectAttempts, the client automatically reconnects
> and the message is successfully sent.
>
> What I need is that the client tries to reconnect, if it fails throw the
> error.
>
> Does anyone what configuration should I use?
>
> Kind Regards,
> Nelson Cintra.
>
>   
>
>
>
> --
> View this message in context: http://activemq.2283324.n4.nabble.com/maxReconnectAttempts-parameter-tp4690272.html
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>
Seems as though it is working as intended, the max reconnects parameter 
means that once it tries that many times it will never try again and the 
connection will close.  If you register and ExceptionListener on the 
connection you should be informed of the error.

-- 
Tim Bish
Sr Software Engineer | RedHat Inc.
tim.bish@redhat.com | www.redhat.com
skype: tabish121 | twitter: @tabish121
blog: http://timbish.blogspot.com/