Word has it you're not supposed to use threads in an EJB. I have a task that I want to run from an app server (in my case JBoss) a limited number of time in parellel. For instance, 4 at once, but not more than 4 since that would overwelme the server. These tasks can each take up to 30 seconds, and I need to design this so it can deal with 1000 or so sitting in a queue waiting to be run. (A little quick math says the jobs at the tail end may wait up to 8 or so hours before being run.) I would like to run this inside the app server, since that's where all the business logic and method that will be called already resides, as opposed to running some external application. Thoughts? -Pete <a href="http://www.budget-ha.com">Budget High Availability</a>
This seems to be a clear-cut case for asynchronous processing via JMS + MDB. You even used the magic word: queue.
Joined: Jan 04, 2002
Chris, JMS with a queue is my initial thought as well. But how do I limit it to X number of transactions being processed at once? Take this a step further and think of a cluster. I want the whole cluster to only try to process (number of nodes)*2 transactions at a time. Thanks for the JMS suggestion, I should have mentioned that, but my real problem is limited the number being processed. Limit to 1? I know how to do that. Limit to a number greater than 1, especially across a cluster? I have no idea. -Pete
Take this a step further and think of a cluster. I want the whole cluster to only try to process (number of nodes)*2 transactions at a time.
Ok. We've reached an area that I'm not too confident about (that happens a lot) but here it goes... The pool size for an MDB in a clustered environment means "per server", i.e. pool size "2" for a cluster of 4 server instances means that there are a total of 8 (2 x 4) listeners for your (distributed!) JMS queue.