[Logo] Terracotta Discussion Forums
  [Search] Search   [Recent Topics] Recent Topics   [Members]  Member Listing   [Groups] Back to home page 
[Register] Register / 
[Login] Login 
[Expert]
Dynamically add job in running quartz instance from same JVM  XML
Forum Index -> Quartz
Author Message
tamal24

neo

Joined: 05/29/2012 01:43:23
Messages: 2
Offline

Hi,

I am newbie in quartz. And I need to start quartz schedular instance first. Then need to create jobs and triggers. And then need to attach them with the running quartz instance.

Following is First program which starz the schedular :

Code:
 
 import org.quartz.Scheduler;
 import org.quartz.SchedulerException;
 import org.quartz.impl.StdSchedulerFactory;
 
 /**
  * @author tamal
  *
  */
 public class QuartzTest {
 
 	/**
 	 * @param args
 	 * @throws InterruptedException 
 	 */
 	public static void main(String[] args) throws InterruptedException {
 		// TODO Auto-generated method stub
 		try {
 					
 			Scheduler scheduler = StdSchedulerFactory.getDefaultScheduler();
 			System.out.println("Name"+scheduler.getSchedulerName());
 			System.out.println("ID"+scheduler.getSchedulerInstanceId());
 			scheduler.start();
 			Thread.sleep(20000); // Sleep 20 second
 			System.out.println("Sleeping");
 			scheduler.shutdown();
 		} catch (SchedulerException e) {
 			// TODO Auto-generated catch block
 			e.printStackTrace();
 		}
 	}
 


Now I want to access this same schedular from another java program running on same JVM

Code:
 
 import org.quartz.Scheduler;
 import org.quartz.SchedulerException;
 import org.quartz.impl.StdSchedulerFactory;
 
 /**
  * @author Tamal
  *
  */
 public class ClientQuartz {
 
 	public static void main(String[] args) throws SchedulerException{
 		Scheduler scheduler1 = StdSchedulerFactory.getDefaultScheduler();
 		
 		System.out.println("ID"+scheduler1.getSchedulerInstanceId());
 		System.out.println("Name"+scheduler1.getSchedulerName());
 		System.out.println("Is Shutdown??"+scheduler1.isShutdown());
 		System.out.println("Is Started??"+scheduler1.isStarted());
 		//scheduler1.
 	}
 }
 


Following is Quartz.properties file
Code:
 org.quartz.scheduler.instanceName = DefaultQuartzScheduler
 org.quartz.scheduler.rmi.export = false
 org.quartz.scheduler.rmi.proxy = false
 org.quartz.scheduler.wrapJobExecutionInUserTransaction = false
 
 org.quartz.threadPool.class = org.quartz.simpl.SimpleThreadPool
 org.quartz.threadPool.threadCount = 10
 org.quartz.threadPool.threadPriority = 5
 org.quartz.threadPool.threadsInheritContextClassLoaderOfInitializingThread = true
 
 org.quartz.jobStore.misfireThreshold = 60000
 
 org.quartz.jobStore.class = org.quartz.simpl.RAMJobStore
 
 


But I am not getting the status of running scheduler from send program.

Can anybody please help.

adahanne

master

Joined: 03/20/2012 23:14:46
Messages: 78
Offline

hello,

Now I want to access this same schedular from another java program running on same JVM  


Starting another main class will start another JVM.
You need to introduce a communication channel between your 2 VMs, for example RMI :

http://quartz-scheduler.org/documentation/quartz-2.x/configuration/ConfigRMI

or even JMX.
tamal24

neo

Joined: 05/29/2012 01:43:23
Messages: 2
Offline

Actually my requirement is to start one quartz scheduler and keep it indefinite.
Then create jobs and triggers from another program and associate them with the running scheduler.
Now my main problem is how I can get the reference of a running scheduler from client program(running on same JVM).
 
Forum Index -> Quartz
Go to:   
Powered by JForum 2.1.7 © JForum Team