You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by "Millies, Sebastian" <Se...@softwareag.com> on 2011/10/05 13:16:55 UTC
How to control thread creation in an embedded broker
Hello there,
I'm using an embedded BrokerService with a single destination,
which is a queue that hands off incoming messages to an SCA
logging service.
Internally, that logging service follows the producer-consumer pattern
with a single blocking queue, so the producer basically gets handed a
message from the broker and puts a log request on the queue.
The problem: as soon as the producer blocks, the broker starts
creating thousands of threads, most of which will also block.
until it runs out of memory. (I have already reduced the stack
available to each thread with the -Xss option.)
How can I control thread creation in the broker (perhaps by supplying
my own ThreadPoolExecutor with an upper bound on the maximum pool size)?
Here's how I create the broker. As you can see, I have already set
the property "dedicatedTaskRunner" to false.
jmsBroker = new BrokerService();
jmsBroker.setUseJmx( true );
jmsBroker.setPersistent( false );
// only relevant when using persistence
jmsBroker.setDeleteAllMessagesOnStartup( true );
jmsBroker.addConnector( "tcp://logginghost:61619" );
jmsBroker.setDedicatedTaskRunner( false );
jmsBroker.start();
-- Sebastian
IDS Scheer Consulting GmbH
Geschäftsführer/Managing Directors: Kamyar Niroumand, Ivo Totev
Sitz/Registered office: Altenkesseler Straße 17, 66115 Saarbrücken, Germany - Registergericht/Commercial register: Saarbrücken HRB 19681
http://www.softwareag.com
RE: How to control thread creation in an embedded broker
Posted by "Millies, Sebastian" <Se...@softwareag.com>.
yes, the size of the thread pool is unbounded, if this is the
right source I'm looking at:
http://activemq.apache.org/maven/5.2.0/activemq-core/apidocs/srchtml/org/apache/activemq/thread/TaskRunnerFactory.html
In fact I was hoping to somehow replace that TaskRunnerFactory.
I'll try to create a compact test case. May take me a few weeks
though...
-- Sebastian
-----Original Message-----
From: Torsten Mielke [mailto:torsten@fusesource.com]
Sent: Wednesday, October 05, 2011 3:41 PM
To: users@activemq.apache.org
Subject: Re: How to control thread creation in an embedded broker
What's the name of the threads being created continuously on your broker?
not using a dedicated task runner is a good idea, as it uses a thread pool instead. However from what I know the size of that thread pool is basically unbounded as well, and if all newly created threads are in use, the broker will just create more threads as needed.
Can you reproduce the problem in an isolated JUnit test?
Torsten Mielke
torsten@fusesource.com
tmielke@blogspot.com
On Oct 5, 2011, at 1:16 PM, Millies, Sebastian wrote:
> Hello there,
>
> I'm using an embedded BrokerService with a single destination,
> which is a queue that hands off incoming messages to an SCA
> logging service.
>
> Internally, that logging service follows the producer-consumer pattern
> with a single blocking queue, so the producer basically gets handed a
> message from the broker and puts a log request on the queue.
>
> The problem: as soon as the producer blocks, the broker starts
> creating thousands of threads, most of which will also block.
> until it runs out of memory. (I have already reduced the stack
> available to each thread with the -Xss option.)
>
> How can I control thread creation in the broker (perhaps by supplying
> my own ThreadPoolExecutor with an upper bound on the maximum pool size)?
>
> Here's how I create the broker. As you can see, I have already set
> the property "dedicatedTaskRunner" to false.
>
> jmsBroker = new BrokerService();
> jmsBroker.setUseJmx( true );
> jmsBroker.setPersistent( false );
> // only relevant when using persistence
> jmsBroker.setDeleteAllMessagesOnStartup( true );
> jmsBroker.addConnector( "tcp://logginghost:61619" );
> jmsBroker.setDedicatedTaskRunner( false );
> jmsBroker.start();
>
> -- Sebastian
> IDS Scheer Consulting GmbH
> Geschäftsführer/Managing Directors: Kamyar Niroumand, Ivo Totev
> Sitz/Registered office: Altenkesseler Straße 17, 66115 Saarbrücken, Germany - Registergericht/Commercial register: Saarbrücken HRB 19681
> http://www.softwareag.com
>
IDS Scheer Consulting GmbH
Geschäftsführer/Managing Directors: Kamyar Niroumand, Ivo Totev
Sitz/Registered office: Altenkesseler Straße 17, 66115 Saarbrücken, Germany - Registergericht/Commercial register: Saarbrücken HRB 19681
http://www.softwareag.com
Re: How to control thread creation in an embedded broker
Posted by Torsten Mielke <to...@fusesource.com>.
What's the name of the threads being created continuously on your broker?
not using a dedicated task runner is a good idea, as it uses a thread pool instead. However from what I know the size of that thread pool is basically unbounded as well, and if all newly created threads are in use, the broker will just create more threads as needed.
Can you reproduce the problem in an isolated JUnit test?
Torsten Mielke
torsten@fusesource.com
tmielke@blogspot.com
On Oct 5, 2011, at 1:16 PM, Millies, Sebastian wrote:
> Hello there,
>
> I'm using an embedded BrokerService with a single destination,
> which is a queue that hands off incoming messages to an SCA
> logging service.
>
> Internally, that logging service follows the producer-consumer pattern
> with a single blocking queue, so the producer basically gets handed a
> message from the broker and puts a log request on the queue.
>
> The problem: as soon as the producer blocks, the broker starts
> creating thousands of threads, most of which will also block.
> until it runs out of memory. (I have already reduced the stack
> available to each thread with the -Xss option.)
>
> How can I control thread creation in the broker (perhaps by supplying
> my own ThreadPoolExecutor with an upper bound on the maximum pool size)?
>
> Here's how I create the broker. As you can see, I have already set
> the property "dedicatedTaskRunner" to false.
>
> jmsBroker = new BrokerService();
> jmsBroker.setUseJmx( true );
> jmsBroker.setPersistent( false );
> // only relevant when using persistence
> jmsBroker.setDeleteAllMessagesOnStartup( true );
> jmsBroker.addConnector( "tcp://logginghost:61619" );
> jmsBroker.setDedicatedTaskRunner( false );
> jmsBroker.start();
>
> -- Sebastian
> IDS Scheer Consulting GmbH
> Geschäftsführer/Managing Directors: Kamyar Niroumand, Ivo Totev
> Sitz/Registered office: Altenkesseler Straße 17, 66115 Saarbrücken, Germany - Registergericht/Commercial register: Saarbrücken HRB 19681
> http://www.softwareag.com
>