You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by itelleria <te...@gmail.com> on 2016/01/13 09:30:49 UTC
ActimeMQ Client's thread management
Hi,
I'm analysing how ActiveMQ client manages the threads to send and receive
JMS messages and I have some questions that I would like to ask.
As far as I've understood when I call connectionFactory.createConnection(),
I get a Connection object which launches a Transport thread in the
background as well as other threads to monitor inactivity. Monitoring with
JConsole I can see these ActiveMQ threads running in the client:
<http://activemq.2283324.n4.nabble.com/file/n4705885/Screen_Shot_2016-01-13_at_08.png>
Setting the useInactivityMonitor property to false, I can disable the
inactivity threads. However, apparently I can’t disable Transport thread.
Therefore, every time a Connection object is created a Transport thread is
launched?
I've seen that Transport threads reads different types of commands from the
socket connected to the broker (keepalive, wirecommand, messagedispatch,
etc) and when a MessageDispatch command is received, it executes the
corresponding MessageListener. So, for asynchronous message delivery I can
understand why the transport thread is created.
However, I think there are some cases when this thread is not needed. For
example, when I send a message I haven't seen that the Transport thread is
used. So, if I open connection only to send a Message, why the Transport
thread is created? I guess that the thread, which has invoked the send()
method, sends the message to the broker without using the transport thread.
Thanks in advance,
Iñigo
--
View this message in context: http://activemq.2283324.n4.nabble.com/ActimeMQ-Client-s-thread-management-tp4705885.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.
Re: ActimeMQ Client's thread management
Posted by Tim Bain <tb...@alumni.duke.edu>.
That's correct.
On Fri, Jan 15, 2016 at 7:45 AM, itelleria <te...@gmail.com> wrote:
> Thank you for your quick reply.
>
> So, to sum up, transport thread is required to send and receive messages
> and
> because of that it's always launched when a connection is created.
>
>
>
>
> --
> View this message in context:
> http://activemq.2283324.n4.nabble.com/ActimeMQ-Client-s-thread-management-tp4705885p4706034.html
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>
Re: ActimeMQ Client's thread management
Posted by itelleria <te...@gmail.com>.
Thank you for your quick reply.
So, to sum up, transport thread is required to send and receive messages and
because of that it's always launched when a connection is created.
--
View this message in context: http://activemq.2283324.n4.nabble.com/ActimeMQ-Client-s-thread-management-tp4705885p4706034.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.
Re: ActimeMQ Client's thread management
Posted by Rob Davies <ra...@gmail.com>.
> On 13 Jan 2016, at 03:30, itelleria <te...@gmail.com> wrote:
>
> Hi,
>
> I'm analysing how ActiveMQ client manages the threads to send and receive
> JMS messages and I have some questions that I would like to ask.
>
> As far as I've understood when I call connectionFactory.createConnection(),
> I get a Connection object which launches a Transport thread in the
> background as well as other threads to monitor inactivity. Monitoring with
> JConsole I can see these ActiveMQ threads running in the client:
>
> <http://activemq.2283324.n4.nabble.com/file/n4705885/Screen_Shot_2016-01-13_at_08.png>
>
> Setting the useInactivityMonitor property to false, I can disable the
> inactivity threads. However, apparently I can’t disable Transport thread.
> Therefore, every time a Connection object is created a Transport thread is
> launched?
Yes - this is correct.
>
> I've seen that Transport threads reads different types of commands from the
> socket connected to the broker (keepalive, wirecommand, messagedispatch,
> etc) and when a MessageDispatch command is received, it executes the
> corresponding MessageListener. So, for asynchronous message delivery I can
> understand why the transport thread is created.
>
> However, I think there are some cases when this thread is not needed. For
> example, when I send a message I haven't seen that the Transport thread is
> used. So, if I open connection only to send a Message, why the Transport
> thread is created? I guess that the thread, which has invoked the send()
> method, sends the message to the broker without using the transport thread.
The transport thread is always required to receive information from the broker by the client - for example, the first interaction is a negotiation between client and broker about which version of the WireFormat to use to send messages. Also, some commands sent from the client need to get a response (e.g. successful login, permission to send messages to a particular destination etc). When you send a message, the client connection would receive a receipt from the broker that the message send was successful. All these interactions require the transport thread to receive interactions from the broker. Hope that helps!
>
> Thanks in advance,
>
> Iñigo
>
>
>
>
>
> --
> View this message in context: http://activemq.2283324.n4.nabble.com/ActimeMQ-Client-s-thread-management-tp4705885.html
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.