You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by developer <sh...@honeywell.com> on 2018/07/19 23:02:49 UTC

Re: Threads started in ActiveMQCPP

Hi,
This question is with reference to activemq cpp version 3.9.3 

Once we call intialize and establish connection by calling 

 activemq::library::ActiveMQCPP::initializeLibrary(); 
x= ActiveMQConnectionFactory() ;
connection = x->createConnection(xy,xz);
connection->start();

and communication starts ..

due to some reason if the connection to broker is lost,  (like disconnected
physical connection or broker stopped)

what is the best way to reestablish communication in this case?
what is the correct sequence...

If i call 
   connection->close();

and then reestablish everything via

activemq::library::ActiveMQCPP::initializeLibrary(); 
x= ActiveMQConnectionFactory() ;
connection = x->createConnection(xy,xz);
connection->start();

communication is back but this is creating some additional threads in qnx
environment.

calling just 
 connection->close();
 connection->start();
doesn't reestablish the connection.










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

Re: Threads started in ActiveMQCPP

Posted by developer <sh...@honeywell.com>.
Hi,
Thanks for the reply. I still have an issue with threads.

I delete all the related data on disconnect ie., connection,
topics,destination, sessions that are created and then reestablish all of it
in the reconnect function.

I don't see a problem in reconnect, send and receive messages, But its just
adding two set of threads on reconnect.

I am not using failover  URI. I call the initialize library once. and i have
not called shutdown in my test.
I read on the forum that "If you don't use failover then you need to catch
exceptions from the 
client calls as well as register an onException handler to know that the 
client connection has failed and then tear down and rebuild the CMS
objects."

I am catching exceptions from CMS objects, which enables me to detect
connection lost and call disconnect.
But wat is the onException handler that i need to register.
Could you please help me get rid of these additional threads.





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

Re: Threads started in ActiveMQCPP

Posted by Timothy Bish <ta...@gmail.com>.
On 07/19/2018 07:02 PM, developer wrote:
> Hi,
> This question is with reference to activemq cpp version 3.9.3
>
> Once we call intialize and establish connection by calling
>
>   activemq::library::ActiveMQCPP::initializeLibrary();
> x= ActiveMQConnectionFactory() ;
> connection = x->createConnection(xy,xz);
> connection->start();
>
> and communication starts ..
>
> due to some reason if the connection to broker is lost,  (like disconnected
> physical connection or broker stopped)
>
> what is the best way to reestablish communication in this case?

Use the failover URI to have the client handle reconnects for you.

> what is the correct sequence...
>
> If i call
>     connection->close();

Be sure to delete the connection as well

> and then reestablish everything via
>
> activemq::library::ActiveMQCPP::initializeLibrary();

Don't call initialize more than once unless you've also shutdown the 
library in between

> x= ActiveMQConnectionFactory() ;
> connection = x->createConnection(xy,xz);
> connection->start();
>
> communication is back but this is creating some additional threads in qnx
> environment.
>
> calling just
>   connection->close();
>   connection->start();
> doesn't reestablish the connection.
>
>
>
>
>
>
>
>
>
>
> --
> Sent from: http://activemq.2283324.n4.nabble.com/ActiveMQ-User-f2341805.html
>

-- 
Tim Bish
twitter: @tabish121
blog: http://timbish.blogspot.com/