开发者

Using Quartz.NET for multiple pages/applications in project

开发者 https://www.devze.com 2023-01-21 13:30 出处:网络
I\'m creating a project that is utilizing Quartz.NET (with ADO.NET DB storage). There is the core component, i.e. the component that executes jobs (console application at the moment, will be a Windows

I'm creating a project that is utilizing Quartz.NET (with ADO.NET DB storage). There is the core component, i.e. the component that executes jobs (console application at the moment, will be a Windows Service), plus multiple web forms where users can add jobs and edit job (edit the datamap values to be specific).

I'm having a bit of an issue with accessing the scheduler from all pages - the core component and the 'add job' page works perfect, with no issues at all. But in them I am essentially doing this in both:

        NameValueCollection properties = new NameValueCollection();

        properties["quartz.scheduler.instanceName"] = "schedService";
        properties["quartz.scheduler.instanceId"] = "sched1";
        properties["quartz.threadPool.type"] = "Quartz.Simpl.SimpleThreadPool, Quartz";
        properties["quartz.threadPool.threadCount"] = "10";
        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.jobStore.clustered"] = "true";
        // if running MS SQL Server we need this
        properties["quartz.jobStore.lockHandler.type"] = "Quartz.Impl.AdoJobStore.UpdateLockRowSemaphore, Quartz";

        properties["quartz.dataSource.default.connectionString"] = "Data Source=CHRIS\\SQLEXPRESS;Initial Catalog=Scheduler;Integrated Security=True;Pooling=False";
        properties["quartz.dataSource.default.provider"] = "SqlServer-20";

        ISchedulerFactory sc开发者_StackOverflow中文版hedService = new StdSchedulerFactory(properties);
        IScheduler sched = schedService.GetScheduler();

When I do the same in the edit page, it informs me that there is already a scheduler named this.

I know I'm probably doing something really stupid, but how is there a way I can declare the scheduler in all my pages so I can access them?


I'm new to Quartz.Net myself, but I'm guessing with clustering set to 'true', you need to use unique names for the scheduler and instances. And I believe what you're getting after is remoting. You should be able to just have one scheduler running and then use remoting to connect to it.

Try this post.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号