views:

610

answers:

2

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.

A: 

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

Cheeso
How would you combine the results? (See the EDIT: part of the question.)
tputkonen
A: 

Just a remimder, EJB 3 framework does all thread management for you. For developer, it is single thread and thread-safe programming. You are not allowed to create your own thread.

bionicoder