public virtual void TestExclusiveJobs() { var deploy = _testRule.Deploy(ESS.FW.Bpm.Model.Bpmn.Bpmn.CreateExecutableProcess("testProcess") .StartEvent() .ServiceTask("task1") .CamundaExpression("${true}") .CamundaAsyncBefore() .ServiceTask("task2") .CamundaExpression("${true}") .CamundaAsyncBefore() .EndEvent() .Done()); var processDefinition = _runtimeService.GetManager <IProcessDefinitionManager>().First(c => c.DeploymentId == deploy.Id); var jobDefinition = _managementService.CreateJobDefinitionQuery(c => c.ActivityId == "task2").FirstOrDefault(); // given that the second task is suspended _managementService.SuspendJobDefinitionById(jobDefinition.Id); // if I start a process instance _runtimeService.StartProcessInstanceByKey("testProcess"); _testRule.WaitForJobExecutorToProcessAllJobs(10000); // then the second task is not Executed //因为其他流程数据没有删除,所以要根据ProcessDefinition来进行查询 //Assert.AreEqual(1, _runtimeService.CreateProcessInstanceQuery().Count()); Assert.AreEqual(1, _runtimeService.GetManager <IExecutionManager>().FindProcessInstanceCountByProcessDefinitionId(processDefinition?.Id)); // there is a suspended job instance var job = _managementService.CreateJobQuery().First(); Assert.AreEqual(job.JobDefinitionId, jobDefinition.Id); Assert.True(job.Suspended); // if I unsuspend the job definition, the job is Executed: _managementService.ActivateJobDefinitionById(jobDefinition.Id, true); _testRule.WaitForJobExecutorToProcessAllJobs(10000); //因为其他流程数据没有删除,所以要根据ProcessDefinition来进行查询 //Assert.AreEqual(0, _runtimeService.CreateProcessInstanceQuery().Count()); Assert.AreEqual(0, _runtimeService.GetManager <IExecutionManager>().FindProcessInstanceCountByProcessDefinitionId(processDefinition?.Id)); }