File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSF and the fly likes running a process in background (in separate thread) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "running a process in background (in separate thread)" Watch "running a process in background (in separate thread)" New topic

running a process in background (in separate thread)

B Nirvan
Ranch Hand

Joined: Oct 20, 2010
Posts: 82
I have a simple situation wherein the user wants to send emails to multiple recipients (that will be looked up from database). The number of recipients is going to be considerable, which means that the whole process will take some time to complete.

Given this scenario, I think the best way to run the "send email" process, would be to run it in a separate thread. Since the J2EE prohibits/discourages creating new threads, I think I will have to use EJB's (either stateless bean marked as @asynchronous, or MessageDriven Bean).

If I am correct in what I said above, which is possibly the best choice for the "send mail" process, asynchronous Stateless Bean or MDB? Also, if I use either of these, how should I notify the user when the process successfully completes or fails.

Another crude thing that came in my mind was to open a new window for the "send mail" option and process the same in that window. But I am not sure about whether, the JSF (or JEE) specs describe the behaviour of one user, multiple windows request processing.

To summarise my doubts,
1. Whether to use EJB or simply create new window and process the "send mail process" in that window.
2. If use of EJB is mandated, whether to use SLSB or MDB
3. If EJB is used, how to notify user of the process success/failure.


I agree. Here's the link:
subject: running a process in background (in separate thread)
It's not a secret anymore!