This content has been marked as final.
Show 3 replies
-
1. Re: WorkManager thread pooling
vickyk Dec 24, 2007 2:01 PM (in response to avzak)"avzak" wrote:
Hi,
We are developing a resource adapter which uses threads in order to process incoming network data. These threads are obtained from the WorkManager instance which uses a BasicThreadPool instance as its thread pooling mechanism.
When we tried to configure the thread pool we noticed that its minimum pool size is always the same as its maximum size.
How/Where did you configure the ThreadPool ?"avzak" wrote:
Is this issue a known bug? if so, when it is expected to be fixed? is it possible to configure the WorkManager to use other implementation of thread pool?
Regards,
Eli Avzak
The JBossWorkManager is configured in $JBOSS_HOME/server/default/deploy/jbossjca-service.xml<mbean code="org.jboss.util.threadpool.BasicThreadPool" name="jboss.jca:service=WorkManagerThreadPool"> <!-- The name that appears in thread names --> <attribute name="Name">WorkManager</attribute> <!-- The maximum amount of work in the queue --> <attribute name="MaximumQueueSize">1024</attribute> <!-- The maximum number of active threads --> <attribute name="MaximumPoolSize">100</attribute> <!-- How long to keep threads alive after their last work (default one minute) --> <attribute name="KeepAliveTime">60000</attribute> </mbean> <mbean code="org.jboss.resource.work.JBossWorkManager" name="jboss.jca:service=WorkManager"> <depends optional-attribute-name="ThreadPoolName">jboss.jca:service=WorkManagerThreadPool</depends> <depends optional-attribute-name="XATerminatorName">jboss:service=TransactionManager</depends> </mbean>
You should be able to plugin custom threadpool implementation here .
But before doing so make sure that your observation regarding the BasicThreadPool is correct . -
2. Re: WorkManager thread pooling
avzak Dec 24, 2007 4:26 PM (in response to avzak)Thanks for the quick reply.
I tried to configure the thread pool in jbossjca-service.xml by adding the
MinimumPoolSize attribute. I also tried to modify the min/max attributes of the WorkManagerThreadPool MBean through the JMX console. Both results the same: the max size cannot be set to a greater value than the min size.
Am i missing something here?
Thanks,
Eli -
3. Re: WorkManager thread pooling
vickyk Dec 27, 2007 3:20 AM (in response to avzak)"avzak" wrote:
Am i missing something here?
No , I looked at the code which displays the Min/Max pool size , here is itpublic int getMinimumPoolSize() { return executor.getCorePoolSize(); } public void setMinimumPoolSize(int size) { synchronized (executor) { // Don't let the min size > max size if (executor.getMaximumPoolSize() < size) { executor.setCorePoolSize(size); executor.setMaximumPoolSize(size); } } } public int getMaximumPoolSize() { return executor.getMaximumPoolSize(); } public void setMaximumPoolSize(int size) { synchronized (executor) { executor.setCorePoolSize(size); executor.setMaximumPoolSize(size); } }
http://anonsvn.jboss.org/repos/common/common-core/trunk/src/main/java/org/jboss/util/threadpool/BasicThreadPool.java
In the above core you will see calling the setMaximumPoolSize() sets executor.setCorePoolSize(size) and the getMinPoolSize() displays the corePoolSize .
Actaully in setMaximumPoolSize(..) the executor.setCorePoolSize(size); should be set only if the size(max size)<getMinimumPoolSize().
Even in older version of the ThreadPool I see the similar implementationpublic void setMaximumPoolSize(int size) { synchronized (executor) { executor.setMinimumPoolSize(size); executor.setMaximumPoolSize(size); // Don't let the min size > max size if (executor.getKeepAliveSize() > size) executor.setKeepAliveSize(size); } }
http://anonsvn.jboss.org/repos/common/common-core/tags/2.0.0/src/main/java/org/jboss/util/threadpool/BasicThreadPool.java
A quicker solution would be to have the custom ThreadPool Implementation which would take care of min/max pool count, you can simply take the jboss code and introduce the check as I have explained earlier .