R – How to process data in multiple threads using EJB3

ejb-3.0multithreading

Sometimes it would be useful to distribute the processing of some data to several threads in an EJB3 session bean.

Let's say that a stateless session bean fetches a lot of data from the database, splits it into several partitions and would like to spawn processing of those partitions in their own, parallel threads. What is the best way to accomplish this? Using message driven beans?

EDIT:
I would also need to somehow get informed, when all the MDBs have finished processing their data, so that the results could be combined and sent for the requester.

Best Solution

Yes. MDB. You are not permitted to start your own threads in an EJB, according to the spec.

Related Question