Get an instance of the scheduler that is being run on a Windows service

前端 未结 2 1939
攒了一身酷
攒了一身酷 2020-12-18 13:09

Let us say I have prepared my Quartz.NET as a Windows service and it is currently being run (with an ADOJobStore running on Sqlite). I need to take

2条回答
  •  不思量自难忘°
    2020-12-18 13:58

    Your service can expose the scheduler by modifying the config file:

    
    
    
    
    
    

    Your Windows app can then accesss it with the appropriate settings:

            //you can put these in a config file too.
            NameValueCollection properties = new NameValueCollection();
            properties["quartz.scheduler.instanceName"] = "RemoteClient";
    
            // set thread pool info
            properties["quartz.threadPool.type"] = "Quartz.Simpl.SimpleThreadPool, Quartz";
            properties["quartz.threadPool.threadCount"] = "5";
            properties["quartz.threadPool.threadPriority"] = "Normal";
    
            // set remoting expoter
            properties["quartz.scheduler.proxy"] = "true";
            properties["quartz.scheduler.proxy.address"] = "tcp://127.0.0.1:555/QuartzScheduler";
    
            ISchedulerFactory sf = new StdSchedulerFactory(properties);
            IScheduler sched = sf.GetScheduler();
    

    The quartz.net master contains really good examples that you won't find in the documentation.

提交回复
热议问题