You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by Wing <ho...@hotmail.com> on 2008/08/12 05:40:32 UTC

How to recover active connection if it is down when using spring?

I am using spring for activemq connection, I would like to reconnect/recover
the broker connection if the broker is down. I know we can use failover: in
the url, but it will cause the tomcat to be held until it can connect to the
broker.
If I set the retry limit in the url, it will not auto reconnect anymore
afterwards.

Any other way to do recovery except configurating the failover url?

I am using org.apache.activemq.pool.PooledConnectionFactory

Thanks.
-- 
View this message in context: http://www.nabble.com/How-to-recover-active-connection-if-it-is-down-when-using-spring--tp18937550p18937550.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: How to recover active connection if it is down when using spring?

Posted by Joe Fernandez <jo...@ttmsolutions.com>.


Hiram Chirino wrote:
> 
> On Thu, Aug 14, 2008 at 2:28 PM, Joe Fernandez
> <jo...@ttmsolutions.com> wrote:
>>
>> If for example you start() a connection with 'failover' and you set
>> maxReconnectAttempts to 2, start() throws an exception after 2 reconnect
>> attempts. That's fine. However, if you then go back and issue the start()
>> again on the same connection, the 2 reconnect attempts will no longer be
>> attempted. The reconnect functionality for that connection is now fubar.
>>
> 
>>I see you want the method to error out on timeout but you want the
>>next method call to attempt to re-establish the connection.  I'll have
>>to thing about how to implement this.
> 
> If you're using failover and start() throws an exception, because it
> reached its max re-connect attempts, then you should be able to invoke it
> again and have it go back through its re-connect process. Right? 
> 
>> I tried calling connection.cleanup() prior to the second start(), because
>> according to this method's comments, calling cleanup() should bring the
>> connection back to a state "as if the connection was just created". This
>> does not help.
>>
> 
>>That's more for the internal jms connection state.. it does not reset
>>the transport which is what is needed.
> 
> Cool. That is what I suspected and thanks for confirming. 
> 
>> Should a JIRA be opened for this?
> 
>>What would be cool is a patch implementing your requested change.
> 
> 
> 
>>
>> Joe
>> http://www.ttmsolutions.com
>>
>>
>>
>> Hiram Chirino wrote:
>>>
>>> Not sure I understand?  So on failure you want to auto reconnect but
>>> you don't want to block until the reconnection happens?  Not this is
>>> possible when connecting to a remote broker.
>>>
>>> Perhaps your best bet is to use an embedded broker so that way you
>>> never have broker failure.  All your operations never block and you
>>> just configure the embedded broker to network with the remote brokers
>>> so that messages get forwarded when they come back online.
>>>
>>>
>>> On Mon, Aug 11, 2008 at 11:40 PM, Wing <ho...@hotmail.com> wrote:
>>>>
>>>> I am using spring for activemq connection, I would like to
>>>> reconnect/recover
>>>> the broker connection if the broker is down. I know we can use
>>>> failover:
>>>> in
>>>> the url, but it will cause the tomcat to be held until it can connect
>>>> to
>>>> the
>>>> broker.
>>>> If I set the retry limit in the url, it will not auto reconnect anymore
>>>> afterwards.
>>>>
>>>> Any other way to do recovery except configurating the failover url?
>>>>
>>>> I am using org.apache.activemq.pool.PooledConnectionFactory
>>>>
>>>> Thanks.
>>>> --
>>>> View this message in context:
>>>> http://www.nabble.com/How-to-recover-active-connection-if-it-is-down-when-using-spring--tp18937550p18937550.html
>>>> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>>>>
>>>>
>>>
>>>
>>>
>>> --
>>> Regards,
>>> Hiram
>>>
>>> Blog: http://hiramchirino.com
>>>
>>> Open Source SOA
>>> http://open.iona.com
>>>
>>>
>>
>> --
>> View this message in context:
>> http://www.nabble.com/How-to-recover-active-connection-if-it-is-down-when-using-spring--tp18937550p18987040.html
>> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>>
>>
> 
> 
> 
> -- 
> Regards,
> Hiram
> 
> Blog: http://hiramchirino.com
> 
> Open Source SOA
> http://open.iona.com
> 
> 

-- 
View this message in context: http://www.nabble.com/How-to-recover-active-connection-if-it-is-down-when-using-spring--tp18937550p18993008.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: How to recover active connection if it is down when using spring?

Posted by Hiram Chirino <hi...@hiramchirino.com>.
On Thu, Aug 14, 2008 at 2:28 PM, Joe Fernandez
<jo...@ttmsolutions.com> wrote:
>
> If for example you start() a connection with 'failover' and you set
> maxReconnectAttempts to 2, start() throws an exception after 2 reconnect
> attempts. That's fine. However, if you then go back and issue the start()
> again on the same connection, the 2 reconnect attempts will no longer be
> attempted. The reconnect functionality for that connection is now fubar.
>

I see you want the method to error out on timeout but you want the
next method call to attempt to re-establish the connection.  I'll have
to thing about how to implement this.

> I tried calling connection.cleanup() prior to the second start(), because
> according to this method's comments, calling cleanup() should bring the
> connection back to a state "as if the connection was just created". This
> does not help.
>

That's more for the internal jms connection state.. it does not reset
the transport which is what is needed.

> Should a JIRA be opened for this?

What would be cool is a patch implementing your requested change.

>
> Joe
> http://www.ttmsolutions.com
>
>
>
> Hiram Chirino wrote:
>>
>> Not sure I understand?  So on failure you want to auto reconnect but
>> you don't want to block until the reconnection happens?  Not this is
>> possible when connecting to a remote broker.
>>
>> Perhaps your best bet is to use an embedded broker so that way you
>> never have broker failure.  All your operations never block and you
>> just configure the embedded broker to network with the remote brokers
>> so that messages get forwarded when they come back online.
>>
>>
>> On Mon, Aug 11, 2008 at 11:40 PM, Wing <ho...@hotmail.com> wrote:
>>>
>>> I am using spring for activemq connection, I would like to
>>> reconnect/recover
>>> the broker connection if the broker is down. I know we can use failover:
>>> in
>>> the url, but it will cause the tomcat to be held until it can connect to
>>> the
>>> broker.
>>> If I set the retry limit in the url, it will not auto reconnect anymore
>>> afterwards.
>>>
>>> Any other way to do recovery except configurating the failover url?
>>>
>>> I am using org.apache.activemq.pool.PooledConnectionFactory
>>>
>>> Thanks.
>>> --
>>> View this message in context:
>>> http://www.nabble.com/How-to-recover-active-connection-if-it-is-down-when-using-spring--tp18937550p18937550.html
>>> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>>>
>>>
>>
>>
>>
>> --
>> Regards,
>> Hiram
>>
>> Blog: http://hiramchirino.com
>>
>> Open Source SOA
>> http://open.iona.com
>>
>>
>
> --
> View this message in context: http://www.nabble.com/How-to-recover-active-connection-if-it-is-down-when-using-spring--tp18937550p18987040.html
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>
>



-- 
Regards,
Hiram

Blog: http://hiramchirino.com

Open Source SOA
http://open.iona.com

Re: How to recover active connection if it is down when using spring?

Posted by Joe Fernandez <jo...@ttmsolutions.com>.
If for example you start() a connection with 'failover' and you set
maxReconnectAttempts to 2, start() throws an exception after 2 reconnect
attempts. That's fine. However, if you then go back and issue the start()
again on the same connection, the 2 reconnect attempts will no longer be
attempted. The reconnect functionality for that connection is now fubar. 

I tried calling connection.cleanup() prior to the second start(), because
according to this method's comments, calling cleanup() should bring the
connection back to a state "as if the connection was just created". This
does not help.

Should a JIRA be opened for this?

Joe
http://www.ttmsolutions.com
   
 

Hiram Chirino wrote:
> 
> Not sure I understand?  So on failure you want to auto reconnect but
> you don't want to block until the reconnection happens?  Not this is
> possible when connecting to a remote broker.
> 
> Perhaps your best bet is to use an embedded broker so that way you
> never have broker failure.  All your operations never block and you
> just configure the embedded broker to network with the remote brokers
> so that messages get forwarded when they come back online.
> 
> 
> On Mon, Aug 11, 2008 at 11:40 PM, Wing <ho...@hotmail.com> wrote:
>>
>> I am using spring for activemq connection, I would like to
>> reconnect/recover
>> the broker connection if the broker is down. I know we can use failover:
>> in
>> the url, but it will cause the tomcat to be held until it can connect to
>> the
>> broker.
>> If I set the retry limit in the url, it will not auto reconnect anymore
>> afterwards.
>>
>> Any other way to do recovery except configurating the failover url?
>>
>> I am using org.apache.activemq.pool.PooledConnectionFactory
>>
>> Thanks.
>> --
>> View this message in context:
>> http://www.nabble.com/How-to-recover-active-connection-if-it-is-down-when-using-spring--tp18937550p18937550.html
>> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>>
>>
> 
> 
> 
> -- 
> Regards,
> Hiram
> 
> Blog: http://hiramchirino.com
> 
> Open Source SOA
> http://open.iona.com
> 
> 

-- 
View this message in context: http://www.nabble.com/How-to-recover-active-connection-if-it-is-down-when-using-spring--tp18937550p18987040.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: How to recover active connection if it is down when using spring?

Posted by Hiram Chirino <hi...@hiramchirino.com>.
Not sure I understand?  So on failure you want to auto reconnect but
you don't want to block until the reconnection happens?  Not this is
possible when connecting to a remote broker.

Perhaps your best bet is to use an embedded broker so that way you
never have broker failure.  All your operations never block and you
just configure the embedded broker to network with the remote brokers
so that messages get forwarded when they come back online.


On Mon, Aug 11, 2008 at 11:40 PM, Wing <ho...@hotmail.com> wrote:
>
> I am using spring for activemq connection, I would like to reconnect/recover
> the broker connection if the broker is down. I know we can use failover: in
> the url, but it will cause the tomcat to be held until it can connect to the
> broker.
> If I set the retry limit in the url, it will not auto reconnect anymore
> afterwards.
>
> Any other way to do recovery except configurating the failover url?
>
> I am using org.apache.activemq.pool.PooledConnectionFactory
>
> Thanks.
> --
> View this message in context: http://www.nabble.com/How-to-recover-active-connection-if-it-is-down-when-using-spring--tp18937550p18937550.html
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>
>



-- 
Regards,
Hiram

Blog: http://hiramchirino.com

Open Source SOA
http://open.iona.com