| Author |
Stop EJB Processing
|
Jeff Storey
Ranch Hand
Joined: Oct 09, 2006
Posts: 118
|
|
I have a stateful bean that does a lot of heavy-duty processing on a server. However, I want the user to be able to stop the processing via a command on a GUI. Basically, I do not want to kill the bean itself, but have it stop its current processing and return to a "ready" state. Is this possible? Thanks, Jeff
|
 |
Justin Chu
Ranch Hand
Joined: Apr 19, 2002
Posts: 209
|
|
|
http://www.theserverside.com/discussions/thread.tss?thread_id=11031
|
 |
Jeff Storey
Ranch Hand
Joined: Oct 09, 2006
Posts: 118
|
|
|
Thanks for the reply Chu. Unfortunately, I'm not sure this relates to my particular problem. I'm not trying ot multi-thread processes on the application server - the order is strict. My multi-threading comes in because I have a GUI launch this process and I want the GUI to also be able to stop this process...
|
 |
Justin Chu
Ranch Hand
Joined: Apr 19, 2002
Posts: 209
|
|
Session (stateful/stateless) EJBs are synchronous, such that, the EJB is doing nothing(in ready state) between invocations of business methods. What you are saying is that, a GUI calls a business method on the bean, and it takes a long time to execute/return. You need a feature to somehow stop this execution, and allow the long running execution to be interrupted/returned. If this is the case, this cannot be done in EJBs, you need to use asynchronous JMS/messaging EJBs. EDIT: I guess it can possibly be achieved if you allow the long running process to poll another "flag" EJB, and have the GUI set the flag to interrupt it. [ October 13, 2006: Message edited by: Chu Tan ]
|
 |
Jeff Storey
Ranch Hand
Joined: Oct 09, 2006
Posts: 118
|
|
I'm somewhat of a newbie to EJBs, so I'm not exactly sure how JMS/MDBs would be used for this...I'm still not sure I understand how I could return during the middle of execution, regardless of what types of beans I'm using. I have basic familiarity with JMS because that is what I use to send asynchronous status messages back to the GUI to display a progress bar. Could you elaborate a little more if possible? Thank you for all of your help thus far. Jeff
|
 |
Justin Chu
Ranch Hand
Joined: Apr 19, 2002
Posts: 209
|
|
Here's a very rough sketch: GUI invokes a stateful ejb to start the job. Stateful ejb creates an entity bean, which serves as flag/identifier/metadata for the job. The stateful ejb asynchronously invokes a MDB, passing as argument the identifier for the job. The MDB manages the execution/interruption of the job. Ejb returns. GUI then polls some JMS queue for the job results. GUI may terminate the process anytime by invoking a method on stateful EJB, which sets the job identifier ejb flag to "terminate". While MDB executes the job, it intermittently checks the placeholder/flag entity EJB to see whether the job has been interrupted. If MDB eventually completes the process, it send results to JMS queue. If MDB terminates the process, it sends a process terminated message to JMS queue. Note: you'll need to look into reentrant and transaction demarcation issues when implementing this.
|
 |
Jeff Storey
Ranch Hand
Joined: Oct 09, 2006
Posts: 118
|
|
|
Seems to make sense. Thanks for the help!
|
 |
 |
|
|
subject: Stop EJB Processing
|
|
|