[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]
2 chained jobs with different triggers  XML
Forum Index -> Quartz
Author Message
hasnaa

neo

Joined: 08/05/2014 02:45:34
Messages: 4
Offline

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?
shazia1

neo

Joined: 10/21/2014 21:33:26
Messages: 7
Offline

Dear Hasnaa,

I am facing the same issue and want to chain 2 jobs. Would you please tell me about the JobChainingJobListener class? I am unable to find it in Quartz library.

Regards,
Shazia.
shazia1

neo

Joined: 10/21/2014 21:33:26
Messages: 7
Offline

I have found the said class. It is in Quartz.Listener namespace :)
akashroy

neo

Joined: 10/23/2014 12:14:33
Messages: 1
Offline

I face same things.
[WWW]
shazia1

neo

Joined: 10/21/2014 21:33:26
Messages: 7
Offline

I want to chain all jobs belonging to a particular job group .. whenever they are added. How it is possible?
 
Forum Index -> Quartz
Go to:   
Powered by JForum 2.1.7 © JForum Team