Wow - I was just playing with long running tasks yesterday for a few hours, I even built a 'LongRunningTask' interface and action :)
I tried to make our implementation completely generic, so that you can make long running tasks easily for all sorts of tasks. Here's how ours works (or will work): - LongRunningTask interface, and a utility task to start/retrieve/remove the current long running task for a given user (session). The restriction here is that each user can only have one LRT in action at any one time. - There's a 'display progress' action, which retrieves the user's current LRT, and displays it's progress (ie percentage complete, name, running time, estimated finishing time) - When the LRT is finished, the 'display progress' action returns SUCCESS instead of INPUT (the display view). The SUCCESS view simply retrieves from the LRT it's finish page and then sends the user there (very easy with WW2/XW) Now, to implement a new LRT, all you need to do is: - extend AbstractLRT, generally involving: - write a run() method which fires off your task (ie reindexing data, importing data or whatever) - write a getPercentageComplete() method which queries the task implementation to work out how much it is complete. This has actually proved quite tricky to calculate in some cases, so it's often rough - in your original action, instead of doing any data processing, you now: - create the LRT and start it - return SUCCESS, which is mapped via XW to the LRT Display action And you're done! Writing new LRTs is usually just a tweak on the old actions, as well as a new simple class or two. For Spring users, I'm also thinking of Springifying my LRT implementations, so that they automatically get populated with manager objects - very neat. They are already wrapped in transaction proxy beans so that the Hibernate transaction spans the length of the LRT. Cheers, Mike On 4/3/04 7:18 AM, "Jason Carreira" ([EMAIL PROTECTED]) penned the words: > If you want to do it like that, I'd suggest a new Result... Like the > chaining result, but asynchronous instead... Then you can start by > chaining now, and move to the async chain later... > >> -----Original Message----- >> From: Aaron Held [mailto:[EMAIL PROTECTED] >> Sent: Wednesday, March 03, 2004 2:49 PM >> To: [EMAIL PROTECTED] >> Subject: Re: [OS-webwork] Long running tasks >> >> >> Jason Carreira wrote: >> >>> You could create a new Dispatcher that takes a namespace and Action >>> name and will kick off a separate thread to execute them... >> You could >>> use the Session to save status information for asynch Action >> execution. >>> >>> >>> >> This sounds like the answer I was looking for. >> So I can build the Action now without worrying threads and when the >> delay becomes too long convert it to an seperate thread. >> >> Thanks, >> -Aaron >> >> >> >> ------------------------------------------------------- >> This SF.Net email is sponsored by: IBM Linux Tutorials >> Free Linux tutorial presented by Daniel Robbins, President >> and CEO of GenToo technologies. Learn everything from >> fundamentals to system >> administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click >> _______________________________________________ >> Opensymphony-webwork mailing list >> [EMAIL PROTECTED] >> https://lists.sourceforge.net/lists/listinfo/opensymphony-webwork >> > > > ------------------------------------------------------- > This SF.Net email is sponsored by: IBM Linux Tutorials > Free Linux tutorial presented by Daniel Robbins, President and CEO of > GenToo technologies. Learn everything from fundamentals to system > administration.http://ads.osdn.com/?ad_id70&alloc_id638&op?k > _______________________________________________ > Opensymphony-webwork mailing list > [EMAIL PROTECTED] > https://lists.sourceforge.net/lists/listinfo/opensymphony-webwork ------------------------------------------------------- This SF.Net email is sponsored by: IBM Linux Tutorials Free Linux tutorial presented by Daniel Robbins, President and CEO of GenToo technologies. Learn everything from fundamentals to system administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click _______________________________________________ Opensymphony-webwork mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/opensymphony-webwork