activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jim Gomes <e.se...@gmail.com>
Subject Re: Apache.NMS.ActiveMQ Threads (C#)
Date Sat, 28 Nov 2015 01:05:13 GMT
megakid,

You stated in your message "We are trying to establish why the C# NMS
library has created all these threads.
​" ​but you are using the Obvs library to create connections for you. It is
just as likely that this library is creating the high number of threads. If
you want to narrow down a possible bug in the NMS implementation, it might
be good to create a simpler test harness without the Obvs library. My usage
of the NMS library does not create a higher than expected number of task
threads. I would suggest also that you keep your consumer object around for
as long as you need it instead of throwing it away as a temp object in the
following line of code:

session.CreateConsumer(dest).Listener += [ourHandler];

Keeping it around and manually maintaining its lifetime will allow you to
control when it is destroyed instead of being garbage collected
unexpectedly.  For reference, here is sample code for synchronous consumer
creation (it could be adapted for asynchronous listeners):
http://activemq.apache.org/nms/nms-simple-synchornous-consumer-example.html

Good luck with your debugging.

On Fri, Nov 27, 2015 at 1:57 PM, Timothy Bish <tabish121@gmail.com> wrote:

> On 11/27/2015 03:29 PM, megakid wrote:
> > Hi all,
> >
> > I'm doing a deep dive debugging exercise on Apache.NMS.ActiveMQ 1.7.1 at
> the
> > moment and struggling!  We recently saw one of our new services in the
> wild
> > with over 300 threads named as "ActiveMQ Task" with
> >
> "Apache.NMS.ActiveMQ.dll!Apache.NMS.ActiveMQ.Threads.DedicatedTaskRunner.Run"
> > as the top stack frame.  We are trying to establish why the C# NMS
> library
> > has created all these threads.  Some questions...
> >
> > I cannot find the Apache.NMS.ActiveMQ source code anywhere, only some
> out of
> > date mentions/links - I assume it is not open sourced any more?
> >
> > I've spent all day trying to reproduce the issue but I can only ever get
> a
> > maximum of 1 thread per session at any point in time (as expected).  I
> am as
> > sure as I can be that we are not creating more than 10 or so sessions
> over a
> > single, global connection (assume that for now) - we call, in short,
> > session.CreateConsumer(dest).Listener += [ourHandler]; - in my debugging
> > I've established that this creates a thread on CreateConsumer, then
> throws
> > that thread away and is replaced with a new one when the Listener += is
> > executed - it doesn't seem to leak anything here.  Are there any other
> > scenarios (failure cases etc) where it may leak these threads?
> >
> > I have looked at the decompiled source to get an indication of when these
> > threads are spawned and, ignoring `dedicatedTaskRunner = false` which I
> know
> > is possible, can only see the FailoverTask and the SessionExecutor that
> uses
> > the DedicatedTaskRunner (which creates threads named "ActiveMQ Task").
> >
> > It is a very busy service so after consulting
> >
> http://activemq.apache.org/how-to-deal-with-large-number-of-threads-in-clients.html
> > I thought it might be due to load - but I can't see where any of that
> code
> > can live inside NMS, am I right in thinking that the C# NMS library is
> > designed to not have more than 1 thread per session (e.g. I should ignore
> > that webpage)?
> >
> > In case anyone is interested, we are using the Obvs library to connect to
> > ActiveMQ - the topic subscription part is here:
> >
> https://github.com/inter8ection/Obvs.ActiveMQ/blob/master/Obvs.ActiveMQ/MessageSource.cs
> >
> > Has anyone else had this issue and what did you do to diagnose it?
> >
> > Thanks very much!
> >
> >
> >
> > --
> > View this message in context:
> http://activemq.2283324.n4.nabble.com/Apache-NMS-ActiveMQ-Threads-C-tp4704338.html
> > Sent from the ActiveMQ - User mailing list archive at Nabble.com.
> >
> Code is here:
>
> http://svn.apache.org/repos/asf/activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk
>
> Happy debugging
>
> --
> Tim Bish
> Sr Software Engineer | RedHat Inc.
> tim.bish@redhat.com | www.redhat.com
> twitter: @tabish121
> blog: http://timbish.blogspot.com/
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message