The biggest issue with threads and EJBs is that threads are a limited resource heavily used by the container, and thread mistakes lead to thread pool leaks that can effectively kill the whole JVM instance.
The biggest issue with threads and EJBs is that threads are a limited resource heavily used by the container, and thread mistakes lead to thread pool leaks that can effectively kill the whole JVM instance. Executor should be better behaved, but it's still going to use up a thread for some length of time; it also may just fail instantly if someone has tuned the container to use up the available threads. Summary is that you're going to be tightrope walking.
1 I agree with charlie, just thought i'd chip in and say that an MDB is almost definitely going to be the better solution. – vickirk Jan 3 at 19:58 Does that mean that I can use Executor within an MDB without any risk? – Vapen Jan 3 at 22:22 1 @Vapen no, see my answer.
– jtahlborn Jan 4 at 20:54.
You "cannot" (should not) use threads, thread pools, executors... all of the above. The point of using an app server is to only write business logic and let the app server do the heavy lifting. If you really, really need to do your own threading, use an EJB 3.1 "singleton" service to manage the threading.
However, as mentioned by others, it's best to leave this to the app server. One way to do parallel processing in an app server is to use MDBs (which it sounds like you already are using), although depending on the type of parallel processing, these may be too heavyweight.
To add to @Charlie Martin's answer, whatever you need the Executor to do, you could design another EJB to perform the same action without the Executor. This allows the new EJB to run in a separate thread handled by the container. The downside is you might have to "reimplement the wheel" since you still do not want to use threads/Executor from the JVM.It also adds to the overhead of getting one EJB to locate/request/connect/call another.
The bottom line is that EJBs are supposed to be worker threads themselves. It may seem like overkill to replicate code instead of use the Executor and it is up to a point. The biggest distinction is one of scale.
Executors will be limited to a single JVM while EJBs can be scaled across JVMs and across servers.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.