The previous article has described the configuration of quartz.net, the use of the and cron expression expressions. Basically, the timing of the task in the background is completed, and the relevant job can be executed correctly according to the execution plan.
Then, if the task needs to be updated, stop a task? Can not be on the server to change the configuration of the relevant job. Therefore, Quartz.net also provides us with a method of remote dispatch. This time, we briefly introduce the configuration and method of the Quartz.net remote dispatching.
1. Configure Quartz.net remote mode execution
Configure the remote Call Quartz exit on the server on which the task is scheduled, quartz.config add the following configuration
this =555=== Httpquartz
A few notes:
1. The address of the client's "quartz.scheduler.proxy.address" configuration is made up of Channeltype,port and bindname configured on the server. Be careful to keep it consistent.
2. When server initialization starts, the process of initiating the job from the database is not in detail here. Next time I introduce myself to do the task scheduling platform, then elaborate.
3. The job server, in fact, even if a service host, in the background control scheduling all Job execution plan.
2. Managing Clients
A) Create a background-managed client, which can be a Web site. It could be something else.
Initialize all scheduler on the remote server
Private StaticIScheduler Scheduler =NULL; Public Static voidInitremotescheduler () {Try{NameValueCollection Properties=NewNameValueCollection (); properties["Quartz.scheduler.instanceName"] ="Schedmaintenanceservice"; properties["Quartz.scheduler.proxy"] ="true"; properties["quartz.scheduler.proxy.address"] =string. Format ("{0}://{1}:{2}/quartzscheduler", scheme, server, port); Ischedulerfactory SF=NewStdschedulerfactory (properties); Scheduler=SF. Getscheduler (); } Catch(Exception ex) {Loghelper.writelog ("initialization of remote task Manager failed"+Ex. StackTrace); } }
b) Add, pause, delete tasks, etc.
/// <summary> ///pausing a task/// </summary> /// <param name= "Jobkey" ></param> Public Static voidPausejob (stringJobkey) { Try{jobkey JK=NewJobkey (Jobkey); if(Scheduler. Checkexists (JK)) {//Pause Task If task already existsScheduler. Pausejob (JK); Loghelper.writelog (string. Format ("task ' {0} ' has been paused", Jobkey)); } } Catch(Exception ex) {Throwex; } }
Here, only said the pause, but the others are similar.
3. Other
In addition, Quartz.net provides crystal-quartz for remote management. CrystalQuartz.Example.RemoteScheduler.Server example. Interested friends, you can manually configure to see.
Quartz.net Summary (iv) Quartz remote Dispatch