Quartz.NET远程 - 调度已经存在 [英] Quartz.NET remoting - scheduler already exists

查看:207
本文介绍了Quartz.NET远程 - 调度已经存在的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建一个使用Quartz.NET,其中利用Windows服务中的应用程序。还有用ASP.NET编写的,一个管理后台,管理员可以增加就业机会和监控调度的状态。当用户登录 - 但是我有与ASP.NET后端的问题



连接在Global.asax文件中,这似乎是在第一次工作取得主仪表板,它工作正常。问题是,当用户点击到不同的页面,它接着说调度schedService'已经存在。



下面是我的Windows服务代码:

 的NameValueCollection性能=新NameValueCollection中(); 

性质[quartz.scheduler.instanceName] =schedService;
性质[quartz.threadPool.type] =Quartz.Simpl.SimpleThreadPool,石英;
性质[quartz.threadPool.threadCount] = THREADCOUNT;
性质[quartz.threadPool.threadPriority] =正常;
性质[quartz.jobStore.misfireThreshold] =60000;
性质[quartz.jobStore.type] =Quartz.Impl.AdoJobStore.JobStoreTX,石英;
性质[quartz.jobStore.useProperties] =假;
性质[quartz.jobStore.dataSource] =默认;
性质[quartz.jobStore.tablePrefix] =QRTZ_;

//
性质[quartz.scheduler.exporter.type] =Quartz.Simpl.RemotingSchedulerExporter,石英;
性质[quartz.scheduler.exporter.port] =555;
性质[quartz.scheduler.exporter.bindName] =QuartzScheduler;
性质[quartz.scheduler.exporter.channelType] =TCP;

//
//如果运行的MS SQL Server,我们需要thisl
性质[quartz.jobStore.lockHandler.type] =Quartz.Impl.AdoJobStore.UpdateLockRowSemaphore,石英;

//配置文件
性质[quartz.dataSource.default.connectionString] =连接;
性质[quartz.dataSource.default.provider] =SqlServer的-20;

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



ASP.NET的Global.asax代码:

 公共静态IScheduler章附表()
{
的NameValueCollection性能=新的NameValueCollection();

性质[quartz.scheduler.instanceName] =schedMaintenanceService;

性质[quartz.scheduler.proxy] =真;
性质[quartz.scheduler.proxy.address] =TCP://本地主机:555 / QuartzScheduler

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



然后,我在每一个ASP.NET页使用:

 公共静态IScheduler章附表= Project.Global.Sched(); 


解决方案

你应该写你的IScheduler作为一个单身


I am creating an application that uses Quartz.NET, which is utilised within a Windows service. There is also an administration backend written in ASP.NET, where administrators can add jobs and monitor the state of the scheduler. I am however having issues with the ASP.NET backend.

The connection is made in the Global.asax file, which seems to work at first - when the user logs on to the main dashboard, it works fine. The problem is when the user clicks onto a different page, where it then says the scheduler 'schedService' already exists.

Here is my Windows Service code:

NameValueCollection properties = new NameValueCollection();

properties["quartz.scheduler.instanceName"] = "schedService";
properties["quartz.threadPool.type"] = "Quartz.Simpl.SimpleThreadPool, Quartz";
properties["quartz.threadPool.threadCount"] = threadcount;
properties["quartz.threadPool.threadPriority"] = "Normal";
properties["quartz.jobStore.misfireThreshold"] = "60000";
properties["quartz.jobStore.type"] = "Quartz.Impl.AdoJobStore.JobStoreTX, Quartz";
properties["quartz.jobStore.useProperties"] = "false";
properties["quartz.jobStore.dataSource"] = "default";
properties["quartz.jobStore.tablePrefix"] = "QRTZ_";

//
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";

//
// if running MS SQL Server we need thisl
properties["quartz.jobStore.lockHandler.type"] = "Quartz.Impl.AdoJobStore.UpdateLockRowSemaphore, Quartz";

// config file
properties["quartz.dataSource.default.connectionString"] = connection;
properties["quartz.dataSource.default.provider"] = "SqlServer-20";

ISchedulerFactory schedService = new StdSchedulerFactory(properties);
IScheduler sched = schedService.GetScheduler();

ASP.NET Global.asax code:

public static IScheduler Sched()
{
    NameValueCollection properties = new NameValueCollection();

    properties["quartz.scheduler.instanceName"] = "schedMaintenanceService";

    properties["quartz.scheduler.proxy"] = "true";
    properties["quartz.scheduler.proxy.address"] = "tcp://localhost:555/QuartzScheduler";

    ISchedulerFactory sf = new StdSchedulerFactory(properties);
    IScheduler sched = sf.GetScheduler();
    return sched;
}

Then I use this in each ASP.NET page:

public static IScheduler sched = Project.Global.Sched();

解决方案

you should write your IScheduler as a singleton

这篇关于Quartz.NET远程 - 调度已经存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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