-
1. Re: Seam and asynchronous threading
klowtherjr Apr 7, 2009 7:13 PM (in response to klowtherjr)Sorry for double posting, but I neglected to mention that the maximum size of the thread pool in which these threads are being created defaults to 10. I've changed the JBoss settings (jboss-service.xml) and the settings in quartz.properties to see if that would help, but it did not have any effect on this particular thread pool.
Thanks again,
Ken
-
-
3. Re: Seam and asynchronous threading
klowtherjr Apr 7, 2009 10:56 PM (in response to klowtherjr)Hi Hugo,
Thanks for the suggestion. FWIW this is in EJB3. I will try the annotation angle, as perhaps I've missed something there.
I can see that the single thread that runs the DefaultMessageListenerContainer. When it receives a message, it calls something that causes what I'll call a
handler
thread to be created. It will create up to 10 of these as subsequent requests arrive. I have found no configuration for this, so I fear it is a default setting buried somewhere in the bowels of the code (perhaps in the concurrency library itself). What I don't know is how to get a hook into it to change it or if that is even possible.Thanks again,
Ken
-
4. Re: Seam and asynchronous threading
gonorrhea Apr 8, 2009 12:01 AM (in response to klowtherjr)don't forget jboss.xml:
http://docs.jboss.org/ejb3/app-server/reference/build/reference/en/html/jbossdeploymentdescriptor.html
from JBoss in Action:
JBoss provides default behavior for most things, keeping vendor specific configuration to a minimum. But for the few things that need to be configured, JBoss provides a proprietary deployment descriptor called jboss.xml. -
5. Re: Seam and asynchronous threading
klowtherjr Apr 15, 2009 7:37 AM (in response to klowtherjr)Let me ask this a little more intelligently now that I've dug into the Seam Framework code a bit and see where we get. From the looks of things, Seam is using its
org.jboss.seam.async.ThreadPoolDispatcher
class to create the listener threads I mentioned earlier. Note the threadPoolSize is hard-wired to 10. This is what I want to configure. That code is as follows:public class ThreadPoolDispatcher extends AbstractDispatcher<Future, TimerSchedule> { private int threadPoolSize = 10; private ScheduledExecutorService executor = Executors.newScheduledThreadPool(threadPoolSize); ... public void setThreadPoolSize(int threadPoolSize) { this.threadPoolSize = threadPoolSize; } }
Other than changing the Seam code and rebuilding, is there a way to configure this value? As you can see, this class does have a
setThreadPoolSize
method, but how do I get a hook into Seam somewhere to set that value in my application for the pool that Seam is using to handle asynchronous events?Thanks!
-
6. Re: Seam and asynchronous threading
kapitanpetko Apr 15, 2009 9:24 AM (in response to klowtherjr)Haven't tried this but
<async:thread-pool-dispatcher thread-pool-size="20" />
in components.xml should work.
-
7. Re: Seam and asynchronous threading
klowtherjr Apr 15, 2009 10:23 PM (in response to klowtherjr)I must admit, this was the most promising suggestion I've seen, but it had no noticable effect. I can see in the logs that it did pick up the change:
'
2009-04-15 15:02:40,541 DEBUG [org.jboss.seam.Component] org.jboss.seam.async.dispatcher.threadPoolSize=5
'However, when the pool is created it grows to 10 threads, adding a thread at a time per asynchronous event. Looking at the http://www.jboss.com/products/seam/async-2.0.xsd, this appears to be the right object to configure, but I'm guessing some code changes have to be made to limit the maximum size of the pool and make it configurable. Given that the previously posted ThreadPoolDispatcher code has it hard-wired, I don't see a way around this with the current version.
-
8. Re: Seam and asynchronous threading
swd847 Apr 15, 2009 10:43 PM (in response to klowtherjr)Is using quartz an option? If so you can control the number of threads using seam.quartz.properties.
-
9. Re: Seam and asynchronous threading
klowtherjr Apr 15, 2009 11:09 PM (in response to klowtherjr)I've been able to successfully modify the maximum number of threads Quartz uses in the past, so I will see how feasible this is to the project higher ups (I just got on the project) to use Quartz instead. I think the preference will be to stick with what is already in place and get it to work. It will come down to how important it is to be able to configure the maximum size of the async thread pool.
Great suggestion, thanks!
-
10. Re: Seam and asynchronous threading
swd847 Apr 15, 2009 11:17 PM (in response to klowtherjr)The reason why it is not working is as follows:
From ThreadPoolDispatcher:
private int threadPoolSize = 10; private ScheduledExecutorService executor = Executors.newScheduledThreadPool(threadPoolSize);
What this means is that the Executor is created when the object is initilised, and before seam has has a chance to change the default value, I will file a JIRA and attach a patch.
-
-
12. Re: Seam and asynchronous threading
klowtherjr Apr 16, 2009 12:23 AM (in response to klowtherjr)That's awesome. Thanks Stuart, that confirms what I was thinking...now I don't feel quite so dumb. :)
-
13. Re: Seam and asynchronous threading
swd847 Apr 16, 2009 12:28 AM (in response to klowtherjr)For now if you need an interim solution you can copy/paste the code for ThreadPoolDispatcher, remove the @Install annotation and set threadPoolSize to whatever you want.