我正在尝试使用 Quartz.Net 来安排我开发的 Windows 服务中的作业。
我在 Onstart 方法中添加了以下代码,scheduler 是一个 Class 属性
私有只读 IScheduler 调度程序;
logger = LogManager.GetLogger(typeof (TelegestionService));
调度程序 = new StdSchedulerFactory().GetScheduler();
var job = new JobDetail("job1", "group1", typeof (HelloJob));
var 触发器 = new SimpleTrigger("trigger1", "group1", runTime);
Scheduler.ScheduleJob(作业,触发器);
这对我来说效果很好。我运行了作业。
现在我正在尝试使调度程序嵌入远程可访问,基于 Quartz 源示例中的Example12(控制台服务器/客户端工作正常)。
<代码>
var 属性 = new NameValueCollection();
属性["quartz.scheduler.instanceName"] = "RemoteServer";
属性[“quartz.threadPool.type”] =“Quartz.Simpl.SimpleThreadPool,Quartz”;
属性[“quartz.threadPool.threadCount”] =“5”;
属性["quartz.threadPool.threadPriority"] = "正常";
属性[“quartz.scheduler.exporter.type”] =“Quartz.Simpl.RemotingSchedulerExporter,Quartz”;
属性[“quartz.scheduler.exporter.port”] =“555”;
属性["quartz.scheduler.exporter.bindName"] = "QuartzScheduler";
属性[“quartz.scheduler.exporter.channelType”] =“tcp”;
调度程序 = new StdSchedulerFactory(properties).GetScheduler();
服务正确启动,调度程序
也正确启动,但我无法使用控制台/Winform 客户端远程调度作业(连接被拒绝)。
我使用 SysInternals TcpView 检查了服务器上的侦听端口,但找不到上面指定的 555 端口。
我怀疑存在与 .Net Remoting 有关的问题,但不知道如何解决此问题。
有什么想法吗?
提前致谢。
I Am trying to use Quartz.Net so as to Schedule Jobs Within a Windows Service that I developped.
I included the following code on the Onstart Method, scheduler is a Class attribute
private readonly IScheduler scheduler;
logger = LogManager.GetLogger(typeof (TelegestionService));
scheduler = new StdSchedulerFactory().GetScheduler();
var job = new JobDetail("job1", "group1", typeof (HelloJob));
var trigger = new SimpleTrigger("trigger1", "group1", runTime);
scheduler.ScheduleJob(job, trigger);
This works fine for me. I got the Job running.
Now I'am trying to make the scheduler embedded remotely accessible, based en Example12 in the Quartz source Examples (the Console Server/Client works fine).
var properties = new NameValueCollection();
properties["quartz.scheduler.instanceName"] = "RemoteServer";
properties["quartz.threadPool.type"] = "Quartz.Simpl.SimpleThreadPool, Quartz";
properties["quartz.threadPool.threadCount"] = "5";
properties["quartz.threadPool.threadPriority"] = "Normal";
properties["quartz.scheduler.exporter.type"] = "Quartz.Simpl.RemotingSchedulerExporter, Quartz";
properties["quartz.scheduler.exporter.port"] = "555";
properties["quartz.scheduler.exporter.bindName"] = "QuartzScheduler";
properties["quartz.scheduler.exporter.channelType"] = "tcp";
scheduler = new StdSchedulerFactory(properties).GetScheduler();
The service starts correctly and so does the scheduler but i cannot remotely schedule the Job using a Console/Winform Client (Connection refused).
I checked the LISTENING ports on my server using SysInternals TcpView and I cannot find the 555 port specified above.
Am suspecting an issue related to .Net Remoting but cannot figure out how to resolve this.
Any ideas ?
Thanks in advance.
发布评论
评论(1)
可以使用 http://topshelf-project.com/ 来托管 Scheduler,它将提供 hostFactory 并使用它可以通过 HttpSelfHostServer 托管主机,http 更好,因为您可以通过控制器调用作业。示例代码如下
希望有所帮助。
could use http://topshelf-project.com/ to host Scheduler which will provide hostFactory and using that could shelf host via HttpSelfHostServer, http is better as you could invoke job via controller. sample code as below
hope this helps.