Re: Multiple instances and background batch threads.
Re: Multiple instances and background batch threads.
- Subject: Re: Multiple instances and background batch threads.
- From: Guido Neitzer <email@hidden>
- Date: Wed, 8 Oct 2008 18:11:50 -0600
On 08.10.2008, at 17:49, Q wrote:
I have a scenario where I need my application to periodically fire
off background batch tasks in a separate thread, but only need one
of the possible instances to perform this task at any given
interval. What technique do people normally use with WO to perform
this sort of election/locking between instances so that only one of
them at a time ever attempts to do the work?
We have some mechanisms to process only unique sets of objects.
What I do on my private project is adding a row to a queue table, this
queue has a column for the instance name, number and possibly thread
identifier that is marked to be used for optimistic locking. Whenever
threads or instances check for entries they do this with a qualifier
for "is null" on that column, before they start working, they save to
the database with this column filled.
Two things can happen now:
1. Save goes through without incident, the thread starts working.
2. Optimistic Locking Failure - break out of the thread and start over
by looking for queue entries that have that column as null.
cug
--
Real World WebObjects Bootcamp at the Big Nerd Ranch:
http://www.bignerdranch.com/classes/real-world_webobjects.shtml
_______________________________________________
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