c# 任务调度篇QuartZ(第三部分:实现管理可视化)

随声附和 提交于 2020-01-24 00:56:02

1.新建一个项目
2.引入QuartZ/CrystalQuartz
3.访问:http://localhost:50611/CrystalQuartzPanel.axd
4.指定StdSchedulerFactory监控参数 端口和可视化项目的 webconfig 下的provider value 端口保持一直

原有项目代码

#region Scheduler

//StdSchedulerFactory factory = new StdSchedulerFactory();
//IScheduler scheduler = await factory.GetScheduler();
IScheduler scheduler = await ScheduleManager.BuildScheduler();
await scheduler.Start();
#endregion

ScheduleManager类

public class ScheduleManager
    {
        public async static Task<IScheduler> BuildScheduler()
        {
            var properties = new NameValueCollection();
            properties["quartz.scheduler.instanceName"] = "后台作业监控系统";

            // 设置线程池
            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"] = "8008";//端口必须和网站新项目端口一致
            properties["quartz.scheduler.exporter.bindName"] = "QuartzScheduler";
            properties["quartz.scheduler.exporter.channelType"] = "tcp";

            var schedulerFactory = new StdSchedulerFactory(properties);
            IScheduler _scheduler = await schedulerFactory.GetScheduler();
            return _scheduler;
        }
    }
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!