Re: Background threads and maintenance applications - how to terminate them safely?
Re: Background threads and maintenance applications - how to terminate them safely?
- Subject: Re: Background threads and maintenance applications - how to terminate them safely?
- From: Lachlan Deck <email@hidden>
- Date: Tue, 23 Oct 2007 12:46:33 +1000
On 23/10/2007, at 11:16 AM, Miguel Arroz wrote:
So, the ideia is to override the isTerminating method, and only
return true is things are safe to terminate?
No. Use that information if needed.
WOLongResponse won't solve my problem, because the user will
introduce the data, get the "OK" page, close the browser and go
away. I don't want him to be waiting, because, unless the whole
server goes down, I'm sure, at that point, that all the data is
valid and can be saved with no problems.
Fair enough. Okay, are you saving the user's data in the database
prior to processing it? That would be the sensible thing to do if you
want to be sure it'll still be there if the app dies.
Then just add a state column to the data that can indicate whether
it's completed, in progress, etc.
Then you can safely have a background thread that dequeues jobs to
process and can safely abort them mid-stream if the app has to go down.
If using WOnder, see ERXApplication.gracefulTerminate.
I'd be looking at java.util.concurrent (e.g., PriorityBlockingQueue,
Execurtors, ExecutorCompletionService) etc.
with regards,
--
Lachlan Deck
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden