【问题标题】:Quartz schedulers controlled from an external app由外部应用程序控制的 Quartz 调度程序
【发布时间】:2015-05-28 23:52:46
【问题描述】:

我目前正在研究 Quartz.NET(版本 2.3.1)。我使用下面的代码(针对每个调度程序)创建了具有不同作业的不同调度程序:

NameValueCollection properties = new NameValueCollection();
properties["quartz.scheduler.instanceName"] = "QuartzSchedulerTest";
properties["quartz.scheduler.instanceId"] = AUTO;
properties["quartz.threadPool.type"] = "Quartz.Simpl.SimpleThreadPool, Quartz";
properties["quartz.threadPool.threadPriority"] = "Normal";
properties["quartz.jobStore.misfireThreshold"] = "60000";
properties["quartz.jobStore.clustered"] = "true";
properties["quartz.jobStore.tablePrefix"] = "QRTZ_";
properties["quartz.jobStore.type"] = "Quartz.Impl.AdoJobStore.JobStoreTX, Quartz";
properties["quartz.jobStore.dataSource"] = "default";
properties["quartz.jobStore.useProperties"] = "false";
properties["quartz.jobStore.driverDelegateType"] = "Quartz.Impl.AdoJobStore.SqlServerDelegate, Quartz";
properties["quartz.dataSource.default.connectionString"] = "myConnString"
properties["quartz.dataSource.default.provider"] = "SqlServer-20";

// Get scheduler
ISchedulerFactory sf = new StdSchedulerFactory(properties);
IScheduler scheduler = sf.GetScheduler();

现在我将所有调度信息存储在 SQL 数据库中,一切正常。

我创建了一个新的控制台应用程序,因为我需要管理所有调度程序(获取调度程序列表、每个调度程序的作业、发送命令以暂停和恢复触发器等...)。 这是我编写的代码,试图让所有现有调度程序都有处理程序:

NameValueCollection properties = new NameValueCollection();
properties["quartz.threadPool.type"] = "Quartz.Simpl.SimpleThreadPool, Quartz";
properties["quartz.threadPool.threadPriority"] = "Normal";
properties["quartz.jobStore.misfireThreshold"] = "60000";
properties["quartz.jobStore.clustered"] = "true";
properties["quartz.jobStore.tablePrefix"] = "QRTZ_";
properties["quartz.jobStore.type"] = "Quartz.Impl.AdoJobStore.JobStoreTX, Quartz";
properties["quartz.jobStore.dataSource"] = "default";
properties["quartz.jobStore.useProperties"] = "false";
properties["quartz.jobStore.driverDelegateType"] = "Quartz.Impl.AdoJobStore.SqlServerDelegate, Quartz";
properties["quartz.dataSource.default.connectionString"] = "myConnString"
properties["quartz.dataSource.default.provider"] = "SqlServer-20";

// Get scheduler
ISchedulerFactory sf = new StdSchedulerFactory(properties);
var schedulers = sf.AllSchedulers;

但没有返回任何处理程序(调度程序计数为 0)。谁能告诉我如何获得所有调度程序?可能吗?

对不起我的英语并提前谢谢。

【问题讨论】:

标签: scheduled-tasks quartz-scheduler scheduling scheduler quartz.net


【解决方案1】:

您必须使用远程处理直接连接到每个调度程序实例。调度程序彼此不知道,也无法获取集群中所有调度程序的列表。

连接到每个调度程序后,您就可以提取正在运行的作业列表并根据需要操作作业调度。如果所有调度程序都在一个集群中,那么您不必连接到所有调度程序来操作作业本身。您可以从任何实例中执行此操作。但是,必须通过单独询问每个调度程序来编译正在运行的作业列表。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-06-30
    • 2018-07-29
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多