View Full Version : Changing parameters to CronTrigger
essarkay
Jan 17th, 2007, 04:06 PM
Hi,
I have a Cron Trigger bean(org.springframework.scheduling.quartz.CronTri ggerBean) ,which will be configured on a weekly basis.
This cron trigger should take start date and end date parameters(basically the last 7 calendar days when the job is going to run).
I would like to know how can i compute the date and update the job data map?
Could someone please help me out?
Thanks,
Essarkay
karldmoore
Jan 17th, 2007, 04:14 PM
When you say its configured weekly, is this managed by the end user? So some guy enters the values that are required. Why don't you just use the standard quartz code to schedule the job? You could always just lookup the trigger from the context (Lookup method injection, factory, etc....) set the required values and then schedule it.
essarkay
Jan 17th, 2007, 04:18 PM
Hi,
It is not managed by end users. It is a weekly job that generates reports.only when the job failed to run, then we do run it manually.
How do i change the job data map in my class that implements the Job interface? (I wont be getting trigger's startTime and next fire Time method in Job Class)
Could you please point out any example, as i really running short of time?
Thanks,
Essarkay
karldmoore
Jan 17th, 2007, 04:23 PM
I'm confused. If its a weekly job, can't you just tell it to run every friday at 10pm via a cron expression. Isn't that enough to do what you want?
karldmoore
Jan 17th, 2007, 04:25 PM
This shows you how to wire the basics up.
http://www.springframework.org/docs/reference/scheduling.html#scheduling-quartz-cron
There are lots of examples here of cron expressions.
http://www.opensymphony.com/quartz/wikidocs/TutorialLesson6.html
essarkay
Jan 17th, 2007, 04:28 PM
Karldmoore,
My requirement is , the job should calculate the start date and end date(my service method needs it):
I deploy the application this friday.
I need to calculate the last seven calendar days from the startTime method of trigger.
Once i get the start time - last 7 days , the trigger calls the service method(start and end date).
once the trigger is executed successfully, it should update the job data map with the start and end date values.
next successive run onwards, i will calculate the dates from the job data map and over rides the start and end date each time i run.
Hope i am clear.
Thanks,
Essarkay
essarkay
Jan 17th, 2007, 04:31 PM
Thanks for the URL.
Infact i had referred the same URL. However, i do not know the following things:
How do i invoke the trigger/job from my service class?
how to update the job data map and calculate timings.
Also what will happen in case if the trigger failed to run?
Essarkay
karldmoore
Jan 17th, 2007, 04:45 PM
Why would you want to invoke the trigger/job from the service?
I would have thought, this should be simple. You need to get hold of a trigger and job detail. You set the values you require and then schedule it, this is just quartz. If want you could define these in Spring and get hold of them somehow (talked about in previous post).
http://www.opensymphony.com/quartz/wikidocs/TutorialLesson3.html
If you want to listen to a job you can add a listener. You can then do whatever you want.
http://www.opensymphony.com/quartz/wikidocs/TutorialLesson8.html
essarkay
Jan 17th, 2007, 04:45 PM
Please ignore the other one . Request you to reply to this one.
It was a mistake. i posted it twice.
Thanks,
Essarkay
essarkay
Jan 17th, 2007, 04:53 PM
Do you mean to say i declare the cron trigger detail, job detail, in spring-quartz.xml file and quartz will fire my job class when the trigger runs?
will i be able to persist the job data map when the trigger runs every time?
How does implementing a job listener help? i need to calculate the next 7 days based on the last run time (which is part of trigger class)?
Thanks,
Essarkay
karldmoore
Jan 18th, 2007, 03:47 PM
I'm still not 100% sure what your trying to achieve. If your just trying to schedule a job and have it recalculate the start and end date upon completion, I would look at the listener reference I added earlier.
essarkay
Jan 18th, 2007, 05:09 PM
Hi,
I could achieve the automatic computation of start and end date(by implementing statefuljob and overriding my job data map). Now i have a different problem.
my cron job is not running and following is what i get from the logs:
I am testing my cron job in the following ways:
i have a cron expression that executes 16 20 every thursday ( 0 20 16 ? * 5 * )
change the clock to 16:18 and start my server and monitor till the time the trigger gets fired.
but my trigger never gets fired.
following are the entries from the table(qrtz_triggers):
TRIGGER_NAME TRIGGER_GROUP JOB_NAME JOB_GROUP IS_VOLATILE DESCRIPTION NEXT_FIRE_TIME PREV_FIRE_TIME TRIGGER_STATE TRIGGER_TYPE START_TIME END_TIME CALENDAR_NAME MISFIRE_INSTR JOB_DATA
----------------------------- ----------------------- ------------ --------------------- -------------- -------------- ----------------- ----------------- ---------------- --------------- ------------- ----------- ---------------- ---------------- -----------
marketWatchSummaryCronTrigger MarketWatchSummaryGroup MWSummaryJob MarketWatchSummaryJob 0 (null) 1169760000000 1169161424643 WAITING CRON 1168549849000 0 (null) 1 Err
Am i doing the right thing?
Thanks,
Essarkay
karldmoore
Jan 19th, 2007, 02:36 AM
Is it possible to see you web.xml and applicationContext.xml?
Powered by vBulletin® Version 4.2.1 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.