This content has been marked as final.
Show 2 replies
-
1. Re: Seam TimerServiceDispatcher - 3 days of wasted time
zahidmaqbool Apr 30, 2008 5:57 AM (in response to zeppelinux.dmitry.diligesoft.com)What problem are you getting in using quartz handler. Seam has built in support for it. I have used quartz with seam quite successfully. If you require any help on this let me know
-
2. Re: Seam TimerServiceDispatcher - 3 days of wasted time
zahidmaqbool Apr 30, 2008 5:59 AM (in response to zeppelinux.dmitry.diligesoft.com)Notihng extra to use it as far as I remeber, just the qurtz library should be there, here is a piece of code:
@Name("asyncDownloader") @AutoCreate public class AsyncAFSDownloader { @Asynchronous @Transactional public QuartzTriggerHandle schedulePayment(@Expiration Date when, @IntervalDuration Long interval, @FinalExpiration Date endDate ) { // do the repeating or long running task until endDate AFSStatusController afsc = new AFSStatusController(); System.out.println("\n\n\n\n-------------------------------------" + "Scheduler Started, Executing Job to Process AFS Response Downloader and State Progressor----------------\n\n\n\n"); QuartzTriggerHandle handle = new QuartzTriggerHandle("AFSTrigger"); ExtractAFSFileContents eafs = new ExtractAFSFileContents(); ArrayList<AFSStatus> afsList = eafs.getExtractedContents("C:\\CCAPS_LOGS\\test.txt"); if(afsList!=null) { for(int i=0; i<afsList.size(); i++) { AFSStatus afsStatus = afsList.get(i); int code=0; if(afsStatus.getStatus().equalsIgnoreCase("Success")) { code=1; } afsc.updateAFSStatus(afsStatus); signalState("AFS-Response", "/to Send-To-AFS", String.valueOf(afsStatus.getApplicationNo()), code); } } return handle; }
And here is the code which starts this:
@Name("asyncAction") public class AsyncAFSAction { @In AsyncAFSDownloader asyncDownloader; @In private FacesMessages facesMessages; public void startAsyncTest() { try { // Schedule the task in the business logic processing code // Starts now, repeats every hour, and ends on May 10th, 2010 Calendar cal = Calendar.getInstance (); cal.set (2040, Calendar.MAY, 10); if(Contexts.getApplicationContext().get("afsScheduler")==null) { QuartzTriggerHandle handle = asyncDownloader.schedulePayment(new Date(), 2*60*60*1000L, cal.getTime()); Contexts.getApplicationContext().set("afsScheduler", handle); facesMessages.add("Scheduler Successfully Started", "Scheduler Successfully Started"); } else { facesMessages.add("Scheduler Already Started", "Scheduler Already Started"); } } catch(Exception e) { facesMessages.add("There was a problem in starting the scheduler or it is already started, check the log files", "There was a problem in starting the scheduler or it is already started, check the log files"); } } }