Am 09.05.2007 um 15:35 schrieb Kieran Kelleher:

I'll try and be brief ......... For stuff like this I create scheduled tasks in the database. ScheduledTasks have a start date (1/1/2007 0:00 for example) and end date(12/31/2008 10:00 for example) and a frequency (1, 2 ... n) and an interval (minutes, hours, days, weeks, months) and a class name that implements ScheduledTask interface. Related to that are many ScheduledTaskEvents, one for each time the task has executed. Since I run multiple instances, I have a standalone app (ScheduleManager.woa for example) that regularly (every 60 seconds for example) checks the schedule table for tasks to be executed, creates new ScheduledTaskEvents in the db for tasks that are to be executed, and then issues a direct action to the multiple instance app with the ScheduledTaskEvent ID. The task is executed and that's it. The ScheduledTaskEvent entity has STATE such as INIT, PROCESSING and DONE. The ScheduledTaskManager only sends DA's for ones with INIT state.


That's an interesting and good approach I will definitely consider. Are you using wget to trigger the DA and then depending of the response getting back mark the task as DONE? Or does the instance that handles the DA write directly to the db? Just thoughts: You could add another field to ScheduledTasks to name the WO app the DA should be sent to allowing to manage a whole bunch of differten apps. To add new tasks the same DA/wget approach could be used so the "client" apps don't need to have the ScheduledTasks EOModel or access to the db respectively.

That's the strategy anyway... it has worked solid for a very long time.

If you try and go the simple route with a simple java Timer, then AFAIK you will lose that task if you restart your app before it gets executed. So, if you want persistence and reliability, I think you have to consider a way to persist your scheduled tasks in the database and have "Singleton" style app in your cluster that triggers the scheduled task events. The to-many tasks events allows me to ensure that every task is absolutely executed which is critical since many of the tasks are related to automatic subscription payments and credit card charges.


Remains the problem that the instance could crash during execution of the DA leaving the task partly finished, but that's life ;-)

jw

HTH, Kieran



On May 9, 2007, at 5:47 AM, Johann Werner wrote:

I recently looked at the NSTimer documentation where a note came up stating that it is obsolete and should not be used for new development. Unfortunately there is no mention of alternatives.

I have a WO app running that should execute a function at certain dates automagically ;) More precisely: people can register for an event and put in different information. At a certain date (to make sense a couple of days ahead of the event) the app should check if all mandatory information has been entered and sends a reminder email to that person if not.

By searching the web the only way if found to implement such behaviour is using a cronjob with wget and a direct action. But by this the app loses control of when the action gets called as it is hardcoded. Additionally I would have to add this call manually in a system config file. I think that's no good as it is not directly related to the app and therefore adds to the install/maintenance complexitiy.

What is the common practice to implement such timing needs?

jw


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/kieran_lists% 40mac.com

This email sent to [EMAIL PROTECTED]


Attachment: smime.p7s
Description: S/MIME cryptographic signature

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to