找上正在Windows服务运行调度的一个实例 [英] Get an instance of the scheduler that is being run on a Windows service

查看:376
本文介绍了找上正在Windows服务运行调度的一个实例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

让我们说,我已准备了我Quartz.NET作为Windows服务,它是当前正在运行(与 ADOJobStore 运行sqlite的)。我需要这个服务的控制权在我的Windows应用程序,这样我就可以阻止它,启动它,添加和删除它的工作,等等。我怎样才能得到这个调度的一个实例?



很抱歉,如果这听起来像你一个简单的问题,但对Quartz.NET文档似乎隔靴搔痒。还有谁知道它只是少数人,他们已经有了自己的生活要过。



更新:
quartz.config我的服务



<$ P的文件$ p> #您可以配置调度在任<石英>配置部分
#或石英属性文件
#配置部分具有优先权

quartz.threadPool.type = Quartz.Simpl.SimpleThreadPool,石英
quartz.threadPool。 THREADCOUNT = 10
quartz.threadPool.threadPriority =正常

#工作初始化插件处理我们的XML阅读,没有它默认使用
quartz.plugin.xml.type =石英。 Plugin.Xml.XMLSchedulingDataProcessorPlugin,石英
quartz.plugin.xml.fileNames =〜/ quartz_jobs.xml

quartz.scheduler.exporter.type = Quartz.Simpl.RemotingSchedulerExporter,石英
quartz.scheduler.exporter.port = 555
quartz.scheduler.exporter.bindName = QuartzScheduler
quartz.scheduler.exporter.channelType = TCP
quartz.scheduler.exporter.channelName = httpQuartz

我使用我的程序,以获得调度的代码:

 的NameValueCollection性能=新的NameValueCollection(); 
性质[quartz.scheduler.instanceName] =RemoteClient;

//设置线程池信息
性质[quartz.threadPool.type] =Quartz.Simpl.SimpleThreadPool,石英;
性质[quartz.threadPool.threadCount] =10;
性质[quartz.threadPool.threadPriority] =正常;

//设置远程expoter
性质[quartz.scheduler.proxy] =真;
性质[quartz.scheduler.proxy.address] =TCP://127.0.0.1:555 / QuartzScheduler

ISchedulerFactory SF =新StdSchedulerFactory(属性);
IScheduler章附表= sf.GetScheduler();



我的服务已安装并处于启动状态,这是登录为本地系统帐户以及它与台式机能够交互


解决方案

您服务,可以通过修改配置文件揭露调度:

 <添加键=quartz.scheduler.exporter.typeVALUE =Quartz.Simpl.RemotingSchedulerExporter,石英/> 
<添加键=quartz.scheduler.exporter.portVALUE =555/>
<添加键=quartz.scheduler.exporter.bindNameVALUE =QuartzScheduler/>
<添加键=quartz.scheduler.exporter.channelTypeVALUE =TCP/>
<添加键=quartz.scheduler.exporter.channelNameVALUE =htt​​pQuartz/>

您的Windows应用程序可以再与适当的设置accesss它:

  //你可以在配置文件中把这些了。 
的NameValueCollection性能=新的NameValueCollection();
性质[quartz.scheduler.instanceName] =RemoteClient;

//设置线程池信息
性质[quartz.threadPool.type] =Quartz.Simpl.SimpleThreadPool,石英;
性质[quartz.threadPool.threadCount] =5;
性质[quartz.threadPool.threadPriority] =正常;

//设置远程expoter
性质[quartz.scheduler.proxy] =真;
性质[quartz.scheduler.proxy.address] =TCP://127.0.0.1:555 / QuartzScheduler

ISchedulerFactory SF =新StdSchedulerFactory(属性);
IScheduler章附表= sf.GetScheduler();



该quartz.net的包含真正的好例子,你不会在文档中找到。


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 control of this service on my Windows application so I can stop it, start it, add and remove jobs from it, etc. How can I get an instance of this scheduler?

Sorry if it sounds like a simple question for you, but the documentation on Quartz.NET seems nowhere near enough. There are only a few people who know about it and they already have their lives to live.

Update: quartz.config file of my service

# You can configure your scheduler in either <quartz> configuration section
# or in quartz properties file
# Configuration section has precedence

quartz.threadPool.type = Quartz.Simpl.SimpleThreadPool, Quartz
quartz.threadPool.threadCount = 10
quartz.threadPool.threadPriority = Normal

# job initialization plugin handles our xml reading, without it defaults are used
quartz.plugin.xml.type = Quartz.Plugin.Xml.XMLSchedulingDataProcessorPlugin, Quartz
quartz.plugin.xml.fileNames = ~/quartz_jobs.xml

quartz.scheduler.exporter.type = Quartz.Simpl.RemotingSchedulerExporter, Quartz
quartz.scheduler.exporter.port = 555
quartz.scheduler.exporter.bindName = QuartzScheduler
quartz.scheduler.exporter.channelType = tcp
quartz.scheduler.exporter.channelName = httpQuartz

The code I am using on my program to get the scheduler:

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"] = "10";
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();

My service is installed and is in Started state and it is log on as a "Local System Account" and it is able interact with the desktop.

解决方案

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

<add key="quartz.scheduler.exporter.type" value="Quartz.Simpl.RemotingSchedulerExporter, Quartz" />
<add key="quartz.scheduler.exporter.port" value="555" />
<add key="quartz.scheduler.exporter.bindName" value="QuartzScheduler" />
<add key="quartz.scheduler.exporter.channelType" value="tcp" />
<add key="quartz.scheduler.exporter.channelName" value="httpQuartz" />

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.

这篇关于找上正在Windows服务运行调度的一个实例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆