Threads started in ActiveMQCPP

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Threads started in ActiveMQCPP

jeffrey
Hi,

When you call activemq::library::ActiveMQCPP::initializeLibrary(); there are multiple threads that get initalized in the process space.  Is there any document or reference listing what the purpose of each of these threads are?  Is there any configuration or parameters that can be used to control which threads and how many threads get started by the library?

Thanks.
Reply | Threaded
Open this post in threaded view
|

Re: Threads started in ActiveMQCPP

tabish121@gmail.com
On 09/09/2014 05:39 PM, jeffrey wrote:

> Hi,
>
> When you call activemq::library::ActiveMQCPP::initializeLibrary(); there are
> multiple threads that get initalized in the process space.  Is there any
> document or reference listing what the purpose of each of these threads are?
> Is there any configuration or parameters that can be used to control which
> threads and how many threads get started by the library?
>
> Thanks.
>
>
>
> --
> View this message in context: http://activemq.2283324.n4.nabble.com/Threads-started-in-ActiveMQCPP-tp4685430.html
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>
There's no configuration for this.  The only documentation would be the
source code itself.

--
Tim Bish
Sr Software Engineer | RedHat Inc.
[hidden email] | www.redhat.com
skype: tabish121 | twitter: @tabish121
blog: http://timbish.blogspot.com/

Reply | Threaded
Open this post in threaded view
|

Re: Threads started in ActiveMQCPP

jeffrey
tabish121@gmail.com wrote
On 09/09/2014 05:39 PM, jeffrey wrote:
> Hi,
>
> When you call activemq::library::ActiveMQCPP::initializeLibrary(); there are
> multiple threads that get initalized in the process space.  Is there any
> document or reference listing what the purpose of each of these threads are?
> Is there any configuration or parameters that can be used to control which
> threads and how many threads get started by the library?
>
> Thanks.
>
>
>
> --
> View this message in context: http://activemq.2283324.n4.nabble.com/Threads-started-in-ActiveMQCPP-tp4685430.html
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>
There's no configuration for this.  The only documentation would be the
source code itself.

--
Tim Bish
Sr Software Engineer | RedHat Inc.
[hidden email] | www.redhat.com
skype: tabish121 | twitter: @tabish121
blog: http://timbish.blogspot.com/

I did a little more analysis and found that the threads start at a later time.  When I create a connection object with this line
consumerConnection = connectionFactory->createConnection();
Six threads are created. A seventh is created with the line
consumer = consumerSession->createConsumer( consumerDestination );
I could understand 2, but I don't know why there are 6 threads created for a connection.  Can you explain the 6 threads off the top of your head?
Reply | Threaded
Open this post in threaded view
|

Re: Threads started in ActiveMQCPP

tabish121@gmail.com
On 09/12/2014 01:37 PM, jeffrey wrote:

> [hidden email] wrote
>> On 09/09/2014 05:39 PM, jeffrey wrote:
>>> Hi,
>>>
>>> When you call activemq::library::ActiveMQCPP::initializeLibrary(); there
>>> are
>>> multiple threads that get initalized in the process space.  Is there any
>>> document or reference listing what the purpose of each of these threads
>>> are?
>>> Is there any configuration or parameters that can be used to control
>>> which
>>> threads and how many threads get started by the library?
>>>
>>> Thanks.
>>>
>>>
>>>
>>> --
>>> View this message in context:
>>> http://activemq.2283324.n4.nabble.com/Threads-started-in-ActiveMQCPP-tp4685430.html
>>> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>>>
>> There's no configuration for this.  The only documentation would be the
>> source code itself.
>>
>> --
>> Tim Bish
>> Sr Software Engineer | RedHat Inc.
>> tim.bish@
>>   | www.redhat.com
>> skype: tabish121 | twitter: @tabish121
>> blog: http://timbish.blogspot.com/
>
> I did a little more analysis and found that the threads start at a later
> time.  When I create a connection object with this line
> *consumerConnection = connectionFactory->createConnection();*
> Six threads are created. A seventh is created with the line
> *consumer = consumerSession->createConsumer( consumerDestination );*
> I could understand 2, but I don't know why there are 6 threads created for a
> connection.  Can you explain the 6 threads off the top of your head?
>
>
>
> --
> View this message in context: http://activemq.2283324.n4.nabble.com/Threads-started-in-ActiveMQCPP-tp4685430p4685515.html
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>
Depends a bit on the URI you are using.

In general there would be:

* The Connection Async processing handler
* The TcpTransport Read thread
* The Inactivity monitor heartbeat thread.
* The FailoverTransport reconnect thread.
* The Session linked dispatch thread.

Plus one or two others that I'm forgetting that handle other async work
needed.

--
Tim Bish
Sr Software Engineer | RedHat Inc.
[hidden email] | www.redhat.com
skype: tabish121 | twitter: @tabish121
blog: http://timbish.blogspot.com/

Reply | Threaded
Open this post in threaded view
|

Re: Threads started in ActiveMQCPP

developer
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
Reply | Threaded
Open this post in threaded view
|

Re: Threads started in ActiveMQCPP

tabish121@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/

Reply | Threaded
Open this post in threaded view
|

Re: Threads started in ActiveMQCPP

developer
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