Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/tensorflow/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# Quartz.NET调度程序。中断(jobKey)正在中断所有活动作业_C#_.net_Quartz.net - Fatal编程技术网

C# Quartz.NET调度程序。中断(jobKey)正在中断所有活动作业

C# Quartz.NET调度程序。中断(jobKey)正在中断所有活动作业,c#,.net,quartz.net,C#,.net,Quartz.net,该方法是否应该只中断jobKey定义的作业?我已经运行了一些测试,它似乎中断了当前运行的所有活动作业 我正在使用RESTfulWebAPI连接到远程调度器以创建/中断/删除作业 Api服务代码: public void DeleteJob(JobKey jobKey) { var scheduler = _clientQuartzScheduler.GetScheduler(); var executingJobs = scheduler.GetCurrentlyExecuti

该方法是否应该只中断jobKey定义的作业?我已经运行了一些测试,它似乎中断了当前运行的所有活动作业

我正在使用RESTfulWebAPI连接到远程调度器以创建/中断/删除作业

Api服务代码:

public void DeleteJob(JobKey jobKey)
{
    var scheduler = _clientQuartzScheduler.GetScheduler();

    var executingJobs = scheduler.GetCurrentlyExecutingJobs();

    if (executingJobs.Any(x => x.JobDetail.Key.Equals(jobKey)))
    {
        scheduler.Interrupt(jobKey);
    }

    scheduler.DeleteJob(jobKey);
}
Quartz远程计划程序应用程序设置包括:

<add key="quartz.threadPool.type" value="Quartz.Simpl.SimpleThreadPool, Quartz" />
<add key="quartz.threadPool.threadCount" value="10" />
<add key="quartz.threadPool.threadPriority" value="Normal" />

<add key="quartz.scheduler.exporter.type" value="Quartz.Simpl.RemotingSchedulerExporter, Quartz" />
<add key="quartz.scheduler.exporter.port" value="555" />
<add key="quartz.scheduler.exporter.bindName" value="QuartzScheduler" />
<add key="quartz.scheduler.exporter.channelType" value="tcp" />
<add key="quartz.scheduler.exporter.channelName" value="httpQuartz" />
<add key="quartz.scheduler.exporter.rejectRemoteRequests" value="false" />

<add key="quartz.jobStore.clustered" value="false" />
<add key="quartz.jobStore.misfireThreshold" value="60000" />
<add key="quartz.jobStore.type" value="Quartz.Impl.AdoJobStore.JobStoreTX, Quartz" />
<add key="quartz.jobStore.lockHandler.type" value="Quartz.Impl.AdoJobStore.UpdateLockRowSemaphore, Quartz" />
<add key="quartz.jobStore.useProperties" value="true" />
<add key="quartz.jobStore.dataSource" value="default" />
<add key="quartz.jobStore.tablePrefix" value="QRTZ_" />
<add key="quartz.jobStore.driverDelegateType" value="Quartz.Impl.AdoJobStore.MySQLDelegate, Quartz" />   

<add key="quartz.dataSource.default.provider" value="MySql-65" />
<add key="quartz.dataSource.default.connectionStringName" value="DatabaseConnectionString" />
properties["quartz.scheduler.instanceName"] = "RemoteClient";
properties["quartz.scheduler.proxy"] = "true";
properties["quartz.threadPool.threadCount"] = "0";
properties["quartz.scheduler.proxy.address"] = address;


要回答这样的问题,只需查看相关方法的源代码(如果可能的话)就更容易了。如果您查看中断的源代码,您将大致看到:

public virtual bool Interrupt(JobKey jobKey)
{
  var currentlyExecutingJobs = this.CurrentlyExecutingJobs;
  bool interruptedAny = false;
  foreach (var executionContext in currentlyExecutingJobs)
  {
    var jobDetail = executionContext.JobDetail;
    if (jobKey.Equals((object) jobDetail.Key))
    {
      var interruptableJob = executionContext.JobInstance as IInterruptableJob;
        if (interruptableJob != null) {
            interruptableJob.Interrupt();
            interruptedAny = true;
        }
        else {
            // throws here
        }
    }
  }
  return interruptedAny;
}

因此,它枚举所有当前作业,并使用匹配的JobKey中断任何作业(顺便说一句,这使得代码中的检查变得不必要-您只需执行scheduler.Interrupt(JobKey))。因此,除非你的所有工作都有匹配的密钥,否则它不应该将它们全部删除。

我很抱歉,但我最终发现了问题所在。结果是我的注册码使用了
NInjectJobFactory
,配置错误


基本上,每个作业执行只运行一个作业实例,因此我设置的停止被中断作业的标志在所有作业执行中共享,从而停止所有作业

嗯,同样的问题,你也可以检查executingJobs.Where(x=>x.JobDetail.Key.Equals(jobKey))返回的是什么他们肯定有不同的作业键(不同的名称,相同的组),但他们有相同的作业类,属于相同的schedulerWell源代码不应该说谎:)如果你说他们都有不同的键,您可以显式地中断它们:foreach(executingJobs.Where(x=>x.JobDetail.Key.Equals(jobKey))((IInterruptableJob)job.interrupt()。但是,这正是中断(jobKey)的含义是的。顺便说一句,我使用的是Quartz的2.3.3版。嗯,这就是为什么我如此困惑,我传递了一个作业的确切作业密钥,但所有作业都被中断(使用不同的作业密钥)。我也在使用相同的版本。我会继续挖掘。可能与基于远程/客户端的体系结构有关。最终找到了它,这是我这边的一个问题,谢谢您的帮助!