You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by BlueSpirit <ad...@gmail.com> on 2018/12/14 09:54:04 UTC

Create connection factory even when broker is down

TL;DR
I would like to instantiate the connection factory even when the broker is
down. How should I achieve this?

I am creating a ActiveMQConnectionFactory using the following URL:
failover:(tcp://localhost:61616)?jms.warnAboutUnstartedConnectionTimeout=30000&initialReconnectDelay=2000&maxReconnectAttempts=2&maxReconnectDelay=2000&startupMaxReconnectAttempts=1

The connectionfactory object is not created if the broker is down at the
time of creation.

As I understand the failover mechanism helps in scenarios when the
connection factory is already created and the ActiveMQ server is restarted.





--
Sent from: http://activemq.2283324.n4.nabble.com/ActiveMQ-User-f2341805.html

Re: Create connection factory even when broker is down

Posted by Tim Bain <tb...@alumni.duke.edu>.
The default behavior if not specified explicitly is to retry forever.
http://activemq.apache.org/failover-transport-reference.html has a
description of that parameter (and all the rest).

Tim

On Dec 18, 2018 3:36 AM, "BlueSpirit" <ad...@gmail.com> wrote:

Sorry for the late reply. If I remove 'maxReconnectAttempts', the receiver
will never be able to reconnect to the server if its restarted.




--
Sent from: http://activemq.2283324.n4.nabble.com/ActiveMQ-User-f2341805.html

Re: Create connection factory even when broker is down

Posted by BlueSpirit <ad...@gmail.com>.
Sorry for the late reply. If I remove 'maxReconnectAttempts', the receiver
will never be able to reconnect to the server if its restarted.



--
Sent from: http://activemq.2283324.n4.nabble.com/ActiveMQ-User-f2341805.html

Re: Create connection factory even when broker is down

Posted by Tim Bain <tb...@alumni.duke.edu>.
Did you try removing both startupMaxConnectAttempts and maxConnectAttempts?
From memory, I believe maxConnectAttempts will be used if
startupMaxConnectAttempts isn't set, so removing startupMaxConnectAttempts
by itself wouldn't be expected to solve the problem.

Tim

On Sun, Dec 16, 2018, 3:31 AM BlueSpirit <adityaguptakanpur@gmail.com wrote:

> Tim Bain wrote
> > Your use of maxReconnectAttempts=2 seems inconsistent with your stated
> > goal
> > of being able to connect to a broker that's not available when the
> > connection factory is created. What are you trying to accomplish with
> that
> > setting, and if you remove it do you get the expected behavior?
> >
> > Tim
> >
> > On Fri, Dec 14, 2018, 7:09 AM Timothy Bish &lt;
>
> > tabish121@
>
> >  wrote:
> >
> > &gt; On 12/14/18 4:54 AM, BlueSpirit wrote:
> >> > TL;DR
> >> > I would like to instantiate the connection factory even when the
> broker
> >> is
> >> > down. How should I achieve this?
> >> >
> >> > I am creating a ActiveMQConnectionFactory using the following URL:
> >> >
> >>
> failover:(tcp://localhost:61616)?jms.warnAboutUnstartedConnectionTimeout=30000&initialReconnectDelay=2000&maxReconnectAttempts=2&maxReconnectDelay=2000&startupMaxReconnectAttempts=1
> >> >
> >> > The connectionfactory object is not created if the broker is down at
> >> the
> >> > time of creation.
> >> >
> >> > As I understand the failover mechanism helps in scenarios when the
> >> > connection factory is already created and the ActiveMQ server is
> >> restarted.
> >> >
> >> >
> >> >
> >> >
> >> >
> >> > --
> >> > Sent from:
> >> http://activemq.2283324.n4.nabble.com/ActiveMQ-User-f2341805.html
> >> >
> >> What error do you receive when trying to create the factory?  You need
> >> to provide more information here to make it clear what is happening.
> >>
> >> --
> >> Tim Bish
> >>
> >>
>
>
> It shows error as: JMSException. Could not connect after trying 2 times.
> Removing starupmaxreconnet doesn't improve.
> I want to silently catch this error.
> My spring container fails to initialize because the broker is down and
> connectionfactory does not initialize.
>
> Based on my config, if the broker is down after the app is up, and later
> restarted, the receiver again connects automatically and starts working. I
> would like to get in this state at the time I am loading my app(broker is
> down at this moment, but will start later)
>
>
>
>
> --
> Sent from:
> http://activemq.2283324.n4.nabble.com/ActiveMQ-User-f2341805.html
>

Re: Create connection factory even when broker is down

Posted by BlueSpirit <ad...@gmail.com>.
Tim Bain wrote
> Your use of maxReconnectAttempts=2 seems inconsistent with your stated
> goal
> of being able to connect to a broker that's not available when the
> connection factory is created. What are you trying to accomplish with that
> setting, and if you remove it do you get the expected behavior?
> 
> Tim
> 
> On Fri, Dec 14, 2018, 7:09 AM Timothy Bish &lt;

> tabish121@

>  wrote:
> 
> &gt; On 12/14/18 4:54 AM, BlueSpirit wrote:
>> > TL;DR
>> > I would like to instantiate the connection factory even when the broker
>> is
>> > down. How should I achieve this?
>> >
>> > I am creating a ActiveMQConnectionFactory using the following URL:
>> >
>> failover:(tcp://localhost:61616)?jms.warnAboutUnstartedConnectionTimeout=30000&initialReconnectDelay=2000&maxReconnectAttempts=2&maxReconnectDelay=2000&startupMaxReconnectAttempts=1
>> >
>> > The connectionfactory object is not created if the broker is down at
>> the
>> > time of creation.
>> >
>> > As I understand the failover mechanism helps in scenarios when the
>> > connection factory is already created and the ActiveMQ server is
>> restarted.
>> >
>> >
>> >
>> >
>> >
>> > --
>> > Sent from:
>> http://activemq.2283324.n4.nabble.com/ActiveMQ-User-f2341805.html
>> >
>> What error do you receive when trying to create the factory?  You need
>> to provide more information here to make it clear what is happening.
>>
>> --
>> Tim Bish
>>
>>


It shows error as: JMSException. Could not connect after trying 2 times.
Removing starupmaxreconnet doesn't improve.
I want to silently catch this error.
My spring container fails to initialize because the broker is down and
connectionfactory does not initialize.

Based on my config, if the broker is down after the app is up, and later
restarted, the receiver again connects automatically and starts working. I
would like to get in this state at the time I am loading my app(broker is
down at this moment, but will start later)




--
Sent from: http://activemq.2283324.n4.nabble.com/ActiveMQ-User-f2341805.html

Re: Create connection factory even when broker is down

Posted by Tim Bain <tb...@alumni.duke.edu>.
Your use of maxReconnectAttempts=2 seems inconsistent with your stated goal
of being able to connect to a broker that's not available when the
connection factory is created. What are you trying to accomplish with that
setting, and if you remove it do you get the expected behavior?

Tim

On Fri, Dec 14, 2018, 7:09 AM Timothy Bish <tabish121@gmail.com wrote:

> On 12/14/18 4:54 AM, BlueSpirit wrote:
> > TL;DR
> > I would like to instantiate the connection factory even when the broker
> is
> > down. How should I achieve this?
> >
> > I am creating a ActiveMQConnectionFactory using the following URL:
> >
> failover:(tcp://localhost:61616)?jms.warnAboutUnstartedConnectionTimeout=30000&initialReconnectDelay=2000&maxReconnectAttempts=2&maxReconnectDelay=2000&startupMaxReconnectAttempts=1
> >
> > The connectionfactory object is not created if the broker is down at the
> > time of creation.
> >
> > As I understand the failover mechanism helps in scenarios when the
> > connection factory is already created and the ActiveMQ server is
> restarted.
> >
> >
> >
> >
> >
> > --
> > Sent from:
> http://activemq.2283324.n4.nabble.com/ActiveMQ-User-f2341805.html
> >
> What error do you receive when trying to create the factory?  You need
> to provide more information here to make it clear what is happening.
>
> --
> Tim Bish
>
>

Re: Create connection factory even when broker is down

Posted by Timothy Bish <ta...@gmail.com>.
On 12/14/18 4:54 AM, BlueSpirit wrote:
> TL;DR
> I would like to instantiate the connection factory even when the broker is
> down. How should I achieve this?
>
> I am creating a ActiveMQConnectionFactory using the following URL:
> failover:(tcp://localhost:61616)?jms.warnAboutUnstartedConnectionTimeout=30000&initialReconnectDelay=2000&maxReconnectAttempts=2&maxReconnectDelay=2000&startupMaxReconnectAttempts=1
>
> The connectionfactory object is not created if the broker is down at the
> time of creation.
>
> As I understand the failover mechanism helps in scenarios when the
> connection factory is already created and the ActiveMQ server is restarted.
>
>
>
>
>
> --
> Sent from: http://activemq.2283324.n4.nabble.com/ActiveMQ-User-f2341805.html
>
What error do you receive when trying to create the factory?  You need 
to provide more information here to make it clear what is happening.

-- 
Tim Bish