[Logo] Terracotta Discussion Forums (LEGACY READ-ONLY ARCHIVE)
  [Search] Search   [Recent Topics] Recent Topics   [Members]  Member Listing   [Groups] Back to home page 
[Register] Register / 
[Login] Login 
[Expert]
Messages posted by: hasnaa  XML
Profile for hasnaa -> Messages posted by hasnaa [4]
Author Message
You can put in your crontrigger 0 0 0 1/3 *? : this one is going to fire every thre days starting on the first day of the month;

If that doesnt respond to your need you can also try with the simpletrigger using .withIntervalInDays(3) but i didn't tested it.
well it actually count 24h from the end of the last job !

You can use in that case cronScheduleBuilder

CronScheduleBuilder.cronSchedule("0 0 0 * * ?")
Did you tried using


Trigger trigger = newTrigger()
.withIdentity("Trigger-1","Trigger-1")
.withSchedule(dailyAtHourAndMinute(00, 00)) // execute job daily at 00:00
.build();
Hello everybody,

i have tried to schedule 2 chained jobs with different triggers

Code:
		SchedulerFactory sf = new StdSchedulerFactory();
 		Scheduler sched = sf.getScheduler();
 		
 		JobDetail job = JobBuilder.newJob(TestJob.class)
 	             .withIdentity("job1", "firstJobGroup").build();
 
 //first job runs when seconds = 30
 
 		 Trigger trigger = TriggerBuilder.newTrigger()
 		            .withIdentity("firstJobTrigger", "firstJobbTriggerGroup")    
 		            .withSchedule(
 				CronScheduleBuilder.cronSchedule("30 * * * * ?")).build(); 
 		
 		job.getJobDataMap().put( "job1", 1 ); 
 
 
 		JobDetail job2 = JobBuilder.newJob(TestJob.class)
 	             .withIdentity("test2", "test2").build(); 
 		job2.getJobDataMap().put( "job2", 2 ); 
 
 
 //second job runs only if mins=01
 		
 		Trigger trigger2 = TriggerBuilder.newTrigger()
 	            .withIdentity("testtrig2", "testrig2")    
 	            .withSchedule(
 			CronScheduleBuilder.cronSchedule("* 01 * * * ?")).build(); 
 
 
 //Chain the 2 jobs
 		JobChainingJobListener chainListener = new JobChainingJobListener( "Chain.Naifr.Stage1.Stage2" ); 
 		chainListener.addJobChainLink( job.getKey(), job2.getKey() ); 
 
 		sched.scheduleJob( job, trigger ); 
 		sched.scheduleJob( job2, trigger2 ); 
 		
 		sched.getListenerManager().addJobListener( chainListener ); 
 		sched.start();


The result is that the 2 jobs are chained ( ruens one after the other) but the 2nd one launch even when mins!=01 !

How can i do to have 2 jobs chained with different triggers?
 
Profile for hasnaa -> Messages posted by hasnaa [4]
Go to:   
Powered by JForum 2.1.7 © JForum Team