From 8086af73a1a566e67277c7b5da4f35346db3bea7 Mon Sep 17 00:00:00 2001 From: Punit Darira Date: Mon, 13 May 2024 17:58:26 -0400 Subject: [PATCH 01/10] feat(engine): Populating process instance id in jobs related to #4205 --- .../bpm/engine/impl/batch/AbstractBatchJobHandler.java | 5 +++++ .../batch/message/MessageCorrelationBatchJobHandler.java | 5 +---- .../impl/batch/variables/BatchSetVariablesHandler.java | 5 +---- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/engine/src/main/java/org/camunda/bpm/engine/impl/batch/AbstractBatchJobHandler.java b/engine/src/main/java/org/camunda/bpm/engine/impl/batch/AbstractBatchJobHandler.java index 1272ca59427..02381914c3b 100644 --- a/engine/src/main/java/org/camunda/bpm/engine/impl/batch/AbstractBatchJobHandler.java +++ b/engine/src/main/java/org/camunda/bpm/engine/impl/batch/AbstractBatchJobHandler.java @@ -169,6 +169,11 @@ protected void createJobEntities(BatchEntity batch, T configuration, String depl ByteArrayEntity configurationEntity = saveConfiguration(byteArrayManager, jobConfiguration); JobEntity job = createBatchJob(batch, configurationEntity); + + if (jobConfiguration.getIds() != null && jobConfiguration.getIds().size() == 1) { + job.setProcessInstanceId(jobConfiguration.getIds().get(0)); + } + job.setDeploymentId(deploymentId); postProcessJob(configuration, job, jobConfiguration); jobManager.insertAndHintJobExecutor(job); diff --git a/engine/src/main/java/org/camunda/bpm/engine/impl/batch/message/MessageCorrelationBatchJobHandler.java b/engine/src/main/java/org/camunda/bpm/engine/impl/batch/message/MessageCorrelationBatchJobHandler.java index 32491d830b4..83511fcc23d 100644 --- a/engine/src/main/java/org/camunda/bpm/engine/impl/batch/message/MessageCorrelationBatchJobHandler.java +++ b/engine/src/main/java/org/camunda/bpm/engine/impl/batch/message/MessageCorrelationBatchJobHandler.java @@ -66,10 +66,7 @@ protected MessageCorrelationBatchConfiguration createJobConfiguration(MessageCor @Override protected void postProcessJob(MessageCorrelationBatchConfiguration configuration, JobEntity job, MessageCorrelationBatchConfiguration jobConfiguration) { - // if there is only one process instance to adjust, set its ID to the job so exclusive scheduling is possible - if (jobConfiguration.getIds() != null && jobConfiguration.getIds().size() == 1) { - job.setProcessInstanceId(jobConfiguration.getIds().get(0)); - } + } @Override diff --git a/engine/src/main/java/org/camunda/bpm/engine/impl/batch/variables/BatchSetVariablesHandler.java b/engine/src/main/java/org/camunda/bpm/engine/impl/batch/variables/BatchSetVariablesHandler.java index e7e5fb85a58..193978d981e 100644 --- a/engine/src/main/java/org/camunda/bpm/engine/impl/batch/variables/BatchSetVariablesHandler.java +++ b/engine/src/main/java/org/camunda/bpm/engine/impl/batch/variables/BatchSetVariablesHandler.java @@ -78,10 +78,7 @@ public String getType() { @Override protected void postProcessJob(BatchConfiguration configuration, JobEntity job, BatchConfiguration jobConfiguration) { - // if there is only one process instance to adjust, set its ID to the job so exclusive scheduling is possible - if (jobConfiguration.getIds() != null && jobConfiguration.getIds().size() == 1) { - job.setProcessInstanceId(jobConfiguration.getIds().get(0)); - } + } protected ByteArrayEntity findByteArrayById(String byteArrayId, CommandContext commandContext) { From 768ad79a5e8e307f83e26ff40dcfe112fb4a5856 Mon Sep 17 00:00:00 2001 From: Punit Darira Date: Sat, 1 Jun 2024 20:46:59 -0400 Subject: [PATCH 02/10] feat(engine): Setting process definition ID in job log related to #4205 --- .../impl/batch/AbstractBatchJobHandler.java | 4 +++ .../RestartProcessInstanceAsyncTest.java | 28 +++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/engine/src/main/java/org/camunda/bpm/engine/impl/batch/AbstractBatchJobHandler.java b/engine/src/main/java/org/camunda/bpm/engine/impl/batch/AbstractBatchJobHandler.java index 02381914c3b..a660e672fc6 100644 --- a/engine/src/main/java/org/camunda/bpm/engine/impl/batch/AbstractBatchJobHandler.java +++ b/engine/src/main/java/org/camunda/bpm/engine/impl/batch/AbstractBatchJobHandler.java @@ -39,6 +39,8 @@ import org.camunda.bpm.engine.impl.util.ClockUtil; import org.camunda.bpm.engine.impl.util.JsonUtil; +import static org.camunda.bpm.engine.impl.RestartProcessInstancesBatchConfigurationJsonConverter.PROCESS_DEFINITION_ID; + /** * Common methods for batch job handlers based on list of ids, providing serialization, configuration instantiation, etc. * @@ -172,6 +174,8 @@ protected void createJobEntities(BatchEntity batch, T configuration, String depl if (jobConfiguration.getIds() != null && jobConfiguration.getIds().size() == 1) { job.setProcessInstanceId(jobConfiguration.getIds().get(0)); + String processDefinitionId = JsonUtil.getString(JsonUtil.asObject(batch.getConfigurationBytes()), PROCESS_DEFINITION_ID, null); + job.setProcessDefinitionId(processDefinitionId); } job.setDeploymentId(deploymentId); diff --git a/engine/src/test/java/org/camunda/bpm/engine/test/api/runtime/RestartProcessInstanceAsyncTest.java b/engine/src/test/java/org/camunda/bpm/engine/test/api/runtime/RestartProcessInstanceAsyncTest.java index 48c5e7100ae..aeb0fccd641 100644 --- a/engine/src/test/java/org/camunda/bpm/engine/test/api/runtime/RestartProcessInstanceAsyncTest.java +++ b/engine/src/test/java/org/camunda/bpm/engine/test/api/runtime/RestartProcessInstanceAsyncTest.java @@ -42,6 +42,7 @@ import org.camunda.bpm.engine.batch.Batch; import org.camunda.bpm.engine.batch.history.HistoricBatch; import org.camunda.bpm.engine.delegate.ExecutionListener; +import org.camunda.bpm.engine.history.HistoricJobLog; import org.camunda.bpm.engine.history.HistoricProcessInstanceQuery; import org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl; import org.camunda.bpm.engine.impl.cfg.multitenancy.TenantIdProvider; @@ -1150,6 +1151,33 @@ public void shouldSetExecutionStartTimeInBatchAndHistory() { Assertions.assertThat(historicBatch.getExecutionStartTime()).isEqualToIgnoringMillis(TEST_DATE); } + @Test + public void shouldSetProcessInstanceAndDefinitionIdInHistoryJobLog() { + // given + + ProcessDefinition processDefinition = testRule.deployAndGetDefinition(ProcessModels.TWO_TASKS_PROCESS); + ProcessInstance processInstance = runtimeService.createProcessInstanceById(processDefinition.getId()) + .startBeforeActivity("userTask1") + .execute(); + runtimeService.deleteProcessInstance(processInstance.getId(), "test"); + Batch batch = runtimeService.restartProcessInstances(processDefinition.getId()) + .startAfterActivity("userTask2") + .processInstanceIds(processInstance.getId()) + .executeAsync(); + helper.executeSeedJob(batch); + List executionJobs = helper.getExecutionJobs(batch); + + // when + helper.executeJob(executionJobs.get(0)); + + // then + HistoricJobLog jobLog = historyService.createHistoricJobLogQuery().jobDefinitionType(Batch.TYPE_PROCESS_INSTANCE_RESTART).list().get(0); + System.out.println(jobLog); + + assertEquals(processInstance.getProcessDefinitionId(), jobLog.getProcessDefinitionId()); + assertEquals(processInstance.getRootProcessInstanceId(), jobLog.getProcessInstanceId()); + } + protected void assertBatchCreated(Batch batch, int processInstanceCount) { assertNotNull(batch); assertNotNull(batch.getId()); From f2a046d522ebcf6aefd2bd1d30e5d9f38965cd40 Mon Sep 17 00:00:00 2001 From: Punit Darira Date: Sat, 29 Jun 2024 00:17:40 -0400 Subject: [PATCH 03/10] fix(engine): Moved setting of processDefinitionId to RestartJobHandler related to #4205 --- .../bpm/engine/impl/RestartProcessInstancesJobHandler.java | 4 ++++ .../bpm/engine/impl/batch/AbstractBatchJobHandler.java | 4 ---- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/engine/src/main/java/org/camunda/bpm/engine/impl/RestartProcessInstancesJobHandler.java b/engine/src/main/java/org/camunda/bpm/engine/impl/RestartProcessInstancesJobHandler.java index cd518f831e8..a0ea181e867 100644 --- a/engine/src/main/java/org/camunda/bpm/engine/impl/RestartProcessInstancesJobHandler.java +++ b/engine/src/main/java/org/camunda/bpm/engine/impl/RestartProcessInstancesJobHandler.java @@ -31,6 +31,9 @@ import org.camunda.bpm.engine.impl.persistence.entity.JobEntity; import org.camunda.bpm.engine.impl.persistence.entity.MessageEntity; import org.camunda.bpm.engine.impl.persistence.entity.ProcessDefinitionEntity; +import org.camunda.bpm.engine.impl.util.JsonUtil; + +import static org.camunda.bpm.engine.impl.RestartProcessInstancesBatchConfigurationJsonConverter.PROCESS_DEFINITION_ID; /** * @@ -54,6 +57,7 @@ protected void postProcessJob(RestartProcessInstancesBatchConfiguration configur .findDeployedProcessDefinitionById(configuration.getProcessDefinitionId()); job.setDeploymentId(processDefinitionEntity.getDeploymentId()); } + job.setProcessDefinitionId(configuration.getProcessDefinitionId()); } @Override diff --git a/engine/src/main/java/org/camunda/bpm/engine/impl/batch/AbstractBatchJobHandler.java b/engine/src/main/java/org/camunda/bpm/engine/impl/batch/AbstractBatchJobHandler.java index a660e672fc6..02381914c3b 100644 --- a/engine/src/main/java/org/camunda/bpm/engine/impl/batch/AbstractBatchJobHandler.java +++ b/engine/src/main/java/org/camunda/bpm/engine/impl/batch/AbstractBatchJobHandler.java @@ -39,8 +39,6 @@ import org.camunda.bpm.engine.impl.util.ClockUtil; import org.camunda.bpm.engine.impl.util.JsonUtil; -import static org.camunda.bpm.engine.impl.RestartProcessInstancesBatchConfigurationJsonConverter.PROCESS_DEFINITION_ID; - /** * Common methods for batch job handlers based on list of ids, providing serialization, configuration instantiation, etc. * @@ -174,8 +172,6 @@ protected void createJobEntities(BatchEntity batch, T configuration, String depl if (jobConfiguration.getIds() != null && jobConfiguration.getIds().size() == 1) { job.setProcessInstanceId(jobConfiguration.getIds().get(0)); - String processDefinitionId = JsonUtil.getString(JsonUtil.asObject(batch.getConfigurationBytes()), PROCESS_DEFINITION_ID, null); - job.setProcessDefinitionId(processDefinitionId); } job.setDeploymentId(deploymentId); From 6999d07c731f61772bbcffbd199f40993cad38d8 Mon Sep 17 00:00:00 2001 From: Punit Darira Date: Sat, 29 Jun 2024 00:19:23 -0400 Subject: [PATCH 04/10] fix(engine): Remove sysout related to #4205 --- .../engine/test/api/runtime/RestartProcessInstanceAsyncTest.java | 1 - 1 file changed, 1 deletion(-) diff --git a/engine/src/test/java/org/camunda/bpm/engine/test/api/runtime/RestartProcessInstanceAsyncTest.java b/engine/src/test/java/org/camunda/bpm/engine/test/api/runtime/RestartProcessInstanceAsyncTest.java index aeb0fccd641..1677179a4f5 100644 --- a/engine/src/test/java/org/camunda/bpm/engine/test/api/runtime/RestartProcessInstanceAsyncTest.java +++ b/engine/src/test/java/org/camunda/bpm/engine/test/api/runtime/RestartProcessInstanceAsyncTest.java @@ -1172,7 +1172,6 @@ public void shouldSetProcessInstanceAndDefinitionIdInHistoryJobLog() { // then HistoricJobLog jobLog = historyService.createHistoricJobLogQuery().jobDefinitionType(Batch.TYPE_PROCESS_INSTANCE_RESTART).list().get(0); - System.out.println(jobLog); assertEquals(processInstance.getProcessDefinitionId(), jobLog.getProcessDefinitionId()); assertEquals(processInstance.getRootProcessInstanceId(), jobLog.getProcessInstanceId()); From 498ef00dbb8ed7c189d17350a61e747baa2a250b Mon Sep 17 00:00:00 2001 From: Punit Darira Date: Tue, 9 Jul 2024 15:21:41 -0400 Subject: [PATCH 05/10] feat(engine): Assert for instance and definitionid in job related to #4205 --- .../test/api/runtime/RestartProcessInstanceAsyncTest.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/engine/src/test/java/org/camunda/bpm/engine/test/api/runtime/RestartProcessInstanceAsyncTest.java b/engine/src/test/java/org/camunda/bpm/engine/test/api/runtime/RestartProcessInstanceAsyncTest.java index 1677179a4f5..5a7d374eb49 100644 --- a/engine/src/test/java/org/camunda/bpm/engine/test/api/runtime/RestartProcessInstanceAsyncTest.java +++ b/engine/src/test/java/org/camunda/bpm/engine/test/api/runtime/RestartProcessInstanceAsyncTest.java @@ -1165,10 +1165,13 @@ public void shouldSetProcessInstanceAndDefinitionIdInHistoryJobLog() { .processInstanceIds(processInstance.getId()) .executeAsync(); helper.executeSeedJob(batch); - List executionJobs = helper.getExecutionJobs(batch); + + Job executionJob = helper.getExecutionJobs(batch).get(0); + assertEquals(processInstance.getProcessDefinitionId(), executionJob.getProcessDefinitionId()); + assertEquals(processInstance.getRootProcessInstanceId(), executionJob.getProcessInstanceId()); // when - helper.executeJob(executionJobs.get(0)); + helper.executeJob(executionJob); // then HistoricJobLog jobLog = historyService.createHistoricJobLogQuery().jobDefinitionType(Batch.TYPE_PROCESS_INSTANCE_RESTART).list().get(0); From 2da3d57ab1cf67fc32588bf78604007e0a15b332 Mon Sep 17 00:00:00 2001 From: Punit Darira Date: Sun, 1 Sep 2024 22:32:26 -0400 Subject: [PATCH 06/10] feat(engine): Tests related to #4334 --- .../RestartProcessInstancesJobHandler.java | 3 -- ...hHistoricDecisionInstanceDeletionTest.java | 14 ++++++++ .../batch/BatchSetRemovalTimeTest.java | 36 +++++++++++++++++++ .../runtime/CorrelateAllMessageBatchTest.java | 1 + .../api/runtime/SetVariablesBatchTest.java | 1 + 5 files changed, 52 insertions(+), 3 deletions(-) diff --git a/engine/src/main/java/org/camunda/bpm/engine/impl/RestartProcessInstancesJobHandler.java b/engine/src/main/java/org/camunda/bpm/engine/impl/RestartProcessInstancesJobHandler.java index a0ea181e867..7f888ec228a 100644 --- a/engine/src/main/java/org/camunda/bpm/engine/impl/RestartProcessInstancesJobHandler.java +++ b/engine/src/main/java/org/camunda/bpm/engine/impl/RestartProcessInstancesJobHandler.java @@ -31,9 +31,6 @@ import org.camunda.bpm.engine.impl.persistence.entity.JobEntity; import org.camunda.bpm.engine.impl.persistence.entity.MessageEntity; import org.camunda.bpm.engine.impl.persistence.entity.ProcessDefinitionEntity; -import org.camunda.bpm.engine.impl.util.JsonUtil; - -import static org.camunda.bpm.engine.impl.RestartProcessInstancesBatchConfigurationJsonConverter.PROCESS_DEFINITION_ID; /** * diff --git a/engine/src/test/java/org/camunda/bpm/engine/test/api/history/BatchHistoricDecisionInstanceDeletionTest.java b/engine/src/test/java/org/camunda/bpm/engine/test/api/history/BatchHistoricDecisionInstanceDeletionTest.java index 14c9a8aca2c..e8fe59943df 100644 --- a/engine/src/test/java/org/camunda/bpm/engine/test/api/history/BatchHistoricDecisionInstanceDeletionTest.java +++ b/engine/src/test/java/org/camunda/bpm/engine/test/api/history/BatchHistoricDecisionInstanceDeletionTest.java @@ -16,6 +16,7 @@ */ package org.camunda.bpm.engine.test.api.history; +import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; @@ -147,6 +148,19 @@ public void removeBatches() { ClockUtil.reset(); } + @Test + public void shouldCreateProcessInstanceRelatedBatchJobsForSingleInvocations(){ + // when + Batch batch = historyService.deleteHistoricDecisionInstancesAsync(decisionInstanceIds, null); + helper.executeSeedJob(batch); + + //then + //Making sure that processInstanceId is set in execution jobs #4205 + assertThat(helper.getExecutionJobs(batch)) + .extracting("processInstanceId") + .containsExactlyInAnyOrder(decisionInstanceIds.toArray()); + } + @Test public void createBatchDeletionByIds() { // when diff --git a/engine/src/test/java/org/camunda/bpm/engine/test/api/history/removaltime/batch/BatchSetRemovalTimeTest.java b/engine/src/test/java/org/camunda/bpm/engine/test/api/history/removaltime/batch/BatchSetRemovalTimeTest.java index b66c814280b..a4a068ff63f 100644 --- a/engine/src/test/java/org/camunda/bpm/engine/test/api/history/removaltime/batch/BatchSetRemovalTimeTest.java +++ b/engine/src/test/java/org/camunda/bpm/engine/test/api/history/removaltime/batch/BatchSetRemovalTimeTest.java @@ -420,6 +420,34 @@ public void shouldSetRemovalTimeForBatch_MultipleInvocationsPerBatchJob() { assertThat(historicBatches.get(1).getRemovalTime()).isEqualTo(REMOVAL_TIME); } + @Test + public void shouldCreateProcessInstanceRelatedBatchJobsForSingleInvocations() { + // given + testRule.getProcessEngineConfiguration().setInvocationsPerBatchJob(1); + + String processInstanceIdOne = testRule.process().userTask().deploy().start(); + String processInstanceIdTwo = testRule.process().userTask().deploy().start(); + + // when + HistoricProcessInstanceQuery query = historyService.createHistoricProcessInstanceQuery(); + Batch batch = historyService.setRemovalTimeToHistoricProcessInstances() + .absoluteRemovalTime(REMOVAL_TIME) + .byQuery(query) + .executeAsync(); + + testRule.executeSeedJobs(batch); + + // then + //Making sure that processInstanceId is set in execution jobs #4205 + List executionJobs = testRule.getExecutionJobs(batch); + assertThat(executionJobs) + .extracting("processInstanceId") + .containsExactlyInAnyOrder(processInstanceIdOne, processInstanceIdTwo); + + // clear + managementService.deleteBatch(batch.getId(), true); + } + @Test public void shouldSetRemovalTime_SingleInvocationPerBatchJob() { // given @@ -2835,6 +2863,9 @@ public void shouldSetExecutionStartTimeInBatchAndHistoryForDecisions() { .putValue("temperature", 32) .putValue("dayType", "Weekend") ).evaluate(); + + HistoricDecisionInstanceQuery query = historyService.createHistoricDecisionInstanceQuery(); + Batch batch = historyService.setRemovalTimeToHistoricDecisionInstances() .absoluteRemovalTime(CURRENT_DATE) .byQuery(historyService.createHistoricDecisionInstanceQuery()) @@ -2851,6 +2882,11 @@ public void shouldSetExecutionStartTimeInBatchAndHistoryForDecisions() { assertThat(batch.getExecutionStartTime()).isEqualToIgnoringMillis(CURRENT_DATE); assertThat(historicBatch.getExecutionStartTime()).isEqualToIgnoringMillis(CURRENT_DATE); + + //Making sure that processInstanceId is set in execution jobs #4205 + assertThat(executionJobs) + .extracting("processInstanceId") + .containsExactlyInAnyOrder(query.list().stream().map(HistoricDecisionInstance::getId).toArray()); } } diff --git a/engine/src/test/java/org/camunda/bpm/engine/test/api/runtime/CorrelateAllMessageBatchTest.java b/engine/src/test/java/org/camunda/bpm/engine/test/api/runtime/CorrelateAllMessageBatchTest.java index f33a254de9c..d6697110b99 100644 --- a/engine/src/test/java/org/camunda/bpm/engine/test/api/runtime/CorrelateAllMessageBatchTest.java +++ b/engine/src/test/java/org/camunda/bpm/engine/test/api/runtime/CorrelateAllMessageBatchTest.java @@ -580,6 +580,7 @@ public void shouldCreateProcessInstanceRelatedBatchJobsForSingleInvocations() { rule.executeSeedJobs(batch); // then + //Making sure that processInstanceId is set in execution jobs #4205 List executionJobs = rule.getExecutionJobs(batch); assertThat(executionJobs) .extracting("processInstanceId") diff --git a/engine/src/test/java/org/camunda/bpm/engine/test/api/runtime/SetVariablesBatchTest.java b/engine/src/test/java/org/camunda/bpm/engine/test/api/runtime/SetVariablesBatchTest.java index 2df88f1eacc..f714784ec05 100644 --- a/engine/src/test/java/org/camunda/bpm/engine/test/api/runtime/SetVariablesBatchTest.java +++ b/engine/src/test/java/org/camunda/bpm/engine/test/api/runtime/SetVariablesBatchTest.java @@ -685,6 +685,7 @@ public void shouldCreateProcessInstanceRelatedBatchJobsForSingleInvocations() { rule.executeSeedJobs(batch); // then + //Making sure that processInstanceId is set in execution jobs #4205 List executionJobs = rule.getExecutionJobs(batch); assertThat(executionJobs) .extracting("processInstanceId") From 8e6ccd2c1fdab66bf641f03c80904f43a93a0e4b Mon Sep 17 00:00:00 2001 From: Punit Darira Date: Mon, 2 Sep 2024 00:57:34 -0400 Subject: [PATCH 07/10] feat(engine): Tests related to #4205 --- .../HistoryServiceAsyncOperationsTest.java | 17 +++++++++ .../ModificationExecutionAsyncTest.java | 7 ++++ .../RuntimeServiceAsyncOperationsTest.java | 21 +++++++++++ .../migration/batch/BatchMigrationTest.java | 35 +++++++++++++++++++ 4 files changed, 80 insertions(+) diff --git a/engine/src/test/java/org/camunda/bpm/engine/test/api/history/HistoryServiceAsyncOperationsTest.java b/engine/src/test/java/org/camunda/bpm/engine/test/api/history/HistoryServiceAsyncOperationsTest.java index 30ba61fcc5b..3455c273c75 100644 --- a/engine/src/test/java/org/camunda/bpm/engine/test/api/history/HistoryServiceAsyncOperationsTest.java +++ b/engine/src/test/java/org/camunda/bpm/engine/test/api/history/HistoryServiceAsyncOperationsTest.java @@ -16,6 +16,8 @@ */ package org.camunda.bpm.engine.test.api.history; +import static org.assertj.core.api.Assertions.assertThat; + import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.hamcrest.CoreMatchers.anyOf; import static org.hamcrest.CoreMatchers.not; @@ -109,6 +111,21 @@ public void testDeleteHistoryProcessInstancesAsyncWithList() throws Exception { assertAllHistoricProcessInstancesAreDeleted(); } + @Test + public void testDeleteHistoryProcessInstances_shouldCreateProcessInstanceRelatedBatchJobsForSingleInvocations() { + //when + Batch batch = historyService.deleteHistoricProcessInstancesAsync(historicProcessInstances, TEST_REASON); + + completeSeedJobs(batch); + List executionJobs = managementService.createJobQuery().jobDefinitionId(batch.getBatchJobDefinitionId()).list(); + + // then + //Making sure that processInstanceId is set in execution jobs #4205 + assertThat(executionJobs) + .extracting("processInstanceId") + .containsExactlyInAnyOrder(historicProcessInstances.toArray()); + } + @Test public void testDeleteHistoryProcessInstancesAsyncWithListForDeletedDeployment() throws Exception { // given a second deployment diff --git a/engine/src/test/java/org/camunda/bpm/engine/test/api/runtime/ModificationExecutionAsyncTest.java b/engine/src/test/java/org/camunda/bpm/engine/test/api/runtime/ModificationExecutionAsyncTest.java index 702ff0bbd03..53162f65674 100644 --- a/engine/src/test/java/org/camunda/bpm/engine/test/api/runtime/ModificationExecutionAsyncTest.java +++ b/engine/src/test/java/org/camunda/bpm/engine/test/api/runtime/ModificationExecutionAsyncTest.java @@ -167,6 +167,13 @@ public void createBatchModification() { Batch batch = runtimeService.createModification(processDefinition.getId()).startAfterActivity("user2").processInstanceIds(processInstanceIds).executeAsync(); assertBatchCreated(batch, 2); + + //Making sure that processInstanceId is set in execution jobs #4205 + helper.executeSeedJob(batch); + List executionJobs = helper.getExecutionJobs(batch); + assertThat(executionJobs) + .extracting("processInstanceId") + .containsExactlyInAnyOrder(processInstanceIds.toArray()); } @Test diff --git a/engine/src/test/java/org/camunda/bpm/engine/test/api/runtime/RuntimeServiceAsyncOperationsTest.java b/engine/src/test/java/org/camunda/bpm/engine/test/api/runtime/RuntimeServiceAsyncOperationsTest.java index fc8d6e5dbe1..e1a05f3fe2a 100644 --- a/engine/src/test/java/org/camunda/bpm/engine/test/api/runtime/RuntimeServiceAsyncOperationsTest.java +++ b/engine/src/test/java/org/camunda/bpm/engine/test/api/runtime/RuntimeServiceAsyncOperationsTest.java @@ -93,6 +93,27 @@ public void testDeleteProcessInstancesAsyncWithList() throws Exception { assertProcessInstancesAreDeleted(); } + @Deployment(resources = { + "org/camunda/bpm/engine/test/api/oneTaskProcess.bpmn20.xml"}) + @Test + public void testDeleteProcessInstances_shouldCreateProcessInstanceRelatedBatchJobsForSingleInvocations() { + // given + List processIds = startTestProcesses(2); + + // when + Batch batch = runtimeService.deleteProcessInstancesAsync(processIds, null, TESTING_INSTANCE_DELETE); + completeSeedJobs(batch); + + List executionJobs = managementService.createJobQuery().jobDefinitionId(batch.getBatchJobDefinitionId()).list(); + + // then + //Making sure that processInstanceId is set in execution jobs #4205 + assertThat(executionJobs) + .extracting("processInstanceId") + .containsExactlyInAnyOrder(processIds.toArray()); + } + + @Deployment(resources = { "org/camunda/bpm/engine/test/api/oneTaskProcess.bpmn20.xml"}) @Test diff --git a/engine/src/test/java/org/camunda/bpm/engine/test/api/runtime/migration/batch/BatchMigrationTest.java b/engine/src/test/java/org/camunda/bpm/engine/test/api/runtime/migration/batch/BatchMigrationTest.java index 96a4cad1756..91e7ae3a93c 100644 --- a/engine/src/test/java/org/camunda/bpm/engine/test/api/runtime/migration/batch/BatchMigrationTest.java +++ b/engine/src/test/java/org/camunda/bpm/engine/test/api/runtime/migration/batch/BatchMigrationTest.java @@ -943,6 +943,41 @@ public void shouldSetExecutionStartTimeInBatchAndHistory() { Assertions.assertThat(historicBatch.getExecutionStartTime()).isEqualToIgnoringMillis(TEST_DATE); } + @Test + public void shouldCreateProcessInstanceRelatedBatchJobsForSingleInvocations() { + RuntimeService runtimeService = engineRule.getRuntimeService(); + int processInstanceCount = 2; + + ProcessDefinition sourceProcessDefinition = migrationRule.deployAndGetDefinition(ProcessModels.ONE_TASK_PROCESS); + ProcessDefinition targetProcessDefinition = migrationRule.deployAndGetDefinition(ProcessModels.ONE_TASK_PROCESS); + + List processInstanceIds = new ArrayList<>(); + for (int i = 0; i < processInstanceCount; i++) { + processInstanceIds.add( + runtimeService.startProcessInstanceById(sourceProcessDefinition.getId()).getId() + ); + } + + MigrationPlan migrationPlan = engineRule.getRuntimeService() + .createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()) + .mapEqualActivities() + .build(); + + // when + Batch batch = runtimeService.newMigration(migrationPlan) + .processInstanceIds(processInstanceIds) + .executeAsync(); + + helper.executeSeedJob(batch); + List executionJobs = helper.getExecutionJobs(batch); + + // then + //Making sure that processInstanceId is set in execution jobs #4205 + assertThat(executionJobs) + .extracting("processInstanceId") + .containsExactlyInAnyOrder(processInstanceIds.toArray()); + } + protected void assertBatchCreated(Batch batch, int processInstanceCount) { assertNotNull(batch); assertNotNull(batch.getId()); From 5e76899310a53eacc5cc475b4293cfac49a682c2 Mon Sep 17 00:00:00 2001 From: Punit Darira Date: Mon, 2 Sep 2024 15:12:31 -0400 Subject: [PATCH 08/10] feat(engine): Tests related to #4205 --- .../removaltime/batch/BatchSetRemovalTimeTest.java | 2 +- .../UpdateProcessInstancesSuspendStateAsyncTest.java | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/engine/src/test/java/org/camunda/bpm/engine/test/api/history/removaltime/batch/BatchSetRemovalTimeTest.java b/engine/src/test/java/org/camunda/bpm/engine/test/api/history/removaltime/batch/BatchSetRemovalTimeTest.java index a4a068ff63f..adb96a1cde1 100644 --- a/engine/src/test/java/org/camunda/bpm/engine/test/api/history/removaltime/batch/BatchSetRemovalTimeTest.java +++ b/engine/src/test/java/org/camunda/bpm/engine/test/api/history/removaltime/batch/BatchSetRemovalTimeTest.java @@ -421,7 +421,7 @@ public void shouldSetRemovalTimeForBatch_MultipleInvocationsPerBatchJob() { } @Test - public void shouldCreateProcessInstanceRelatedBatchJobsForSingleInvocations() { + public void testRemovalTimeProcess_shouldCreateProcessInstanceRelatedBatchJobsForSingleInvocations() { // given testRule.getProcessEngineConfiguration().setInvocationsPerBatchJob(1); diff --git a/engine/src/test/java/org/camunda/bpm/engine/test/api/runtime/UpdateProcessInstancesSuspendStateAsyncTest.java b/engine/src/test/java/org/camunda/bpm/engine/test/api/runtime/UpdateProcessInstancesSuspendStateAsyncTest.java index 7a9700ec3a9..966d3c1b1cc 100644 --- a/engine/src/test/java/org/camunda/bpm/engine/test/api/runtime/UpdateProcessInstancesSuspendStateAsyncTest.java +++ b/engine/src/test/java/org/camunda/bpm/engine/test/api/runtime/UpdateProcessInstancesSuspendStateAsyncTest.java @@ -194,9 +194,20 @@ public void testBatchActivationById() { // when Batch suspendprocess = runtimeService.updateProcessInstanceSuspensionState().byProcessInstanceIds(Arrays.asList(processInstance1.getId(), processInstance2.getId())).suspendAsync(); helper.completeSeedJobs(suspendprocess); + + //Making sure that processInstanceId is set in execution jobs #4205 + assertThat(helper.getExecutionJobs(suspendprocess)) + .extracting("processInstanceId") + .containsExactlyInAnyOrder(processInstance1.getId(), processInstance2.getId()); + helper.executeJobs(suspendprocess); Batch activateprocess = runtimeService.updateProcessInstanceSuspensionState().byProcessInstanceIds(Arrays.asList(processInstance1.getId(), processInstance2.getId())).activateAsync(); helper.completeSeedJobs(activateprocess); + + //Making sure that processInstanceId is set in execution jobs #4205 + assertThat(helper.getExecutionJobs(activateprocess)) + .extracting("processInstanceId") + .containsExactlyInAnyOrder(processInstance1.getId(), processInstance2.getId()); helper.executeJobs(activateprocess); From 4b4f156d6e5b8349c340c212fe02f79e6b87d830 Mon Sep 17 00:00:00 2001 From: Yana Vasileva Date: Thu, 5 Sep 2024 20:34:48 +0200 Subject: [PATCH 09/10] wip --- .../impl/batch/AbstractBatchJobHandler.java | 9 ++++++- .../producer/DefaultHistoryEventProducer.java | 25 +++++++++++++++++++ .../impl/persistence/entity/JobEntity.java | 1 + ...hHistoricDecisionInstanceDeletionTest.java | 16 +----------- .../batch/BatchSetRemovalTimeTest.java | 7 ------ .../ModificationExecutionAsyncTest.java | 2 +- .../api/runtime/SetVariablesBatchTest.java | 1 - 7 files changed, 36 insertions(+), 25 deletions(-) diff --git a/engine/src/main/java/org/camunda/bpm/engine/impl/batch/AbstractBatchJobHandler.java b/engine/src/main/java/org/camunda/bpm/engine/impl/batch/AbstractBatchJobHandler.java index 02381914c3b..0cdb9804944 100644 --- a/engine/src/main/java/org/camunda/bpm/engine/impl/batch/AbstractBatchJobHandler.java +++ b/engine/src/main/java/org/camunda/bpm/engine/impl/batch/AbstractBatchJobHandler.java @@ -21,6 +21,8 @@ import java.util.Iterator; import java.util.List; import java.util.Map; + +import org.camunda.bpm.engine.impl.batch.removaltime.DecisionSetRemovalTimeJobHandler; import org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl; import org.camunda.bpm.engine.impl.context.Context; import org.camunda.bpm.engine.impl.db.DbEntity; @@ -28,6 +30,7 @@ import org.camunda.bpm.engine.impl.db.entitymanager.OptimisticLockingResult; import org.camunda.bpm.engine.impl.db.entitymanager.operation.DbEntityOperation; import org.camunda.bpm.engine.impl.db.entitymanager.operation.DbOperation; +import org.camunda.bpm.engine.impl.dmn.batch.DeleteHistoricDecisionInstancesJobHandler; import org.camunda.bpm.engine.impl.interceptor.CommandContext; import org.camunda.bpm.engine.impl.jobexecutor.JobDeclaration; import org.camunda.bpm.engine.impl.persistence.entity.ByteArrayEntity; @@ -170,7 +173,11 @@ protected void createJobEntities(BatchEntity batch, T configuration, String depl JobEntity job = createBatchJob(batch, configurationEntity); - if (jobConfiguration.getIds() != null && jobConfiguration.getIds().size() == 1) { + if (jobConfiguration.getIds() != null && jobConfiguration.getIds().size() == 1 + && !(this instanceof DecisionSetRemovalTimeJobHandler) + && !(this instanceof DeleteHistoricDecisionInstancesJobHandler) +// && !(this instanceof DeleteHistoricDecisionInstancesJobHandler) + ) { job.setProcessInstanceId(jobConfiguration.getIds().get(0)); } diff --git a/engine/src/main/java/org/camunda/bpm/engine/impl/history/producer/DefaultHistoryEventProducer.java b/engine/src/main/java/org/camunda/bpm/engine/impl/history/producer/DefaultHistoryEventProducer.java index 25b41dbf4a3..6247a05983e 100644 --- a/engine/src/main/java/org/camunda/bpm/engine/impl/history/producer/DefaultHistoryEventProducer.java +++ b/engine/src/main/java/org/camunda/bpm/engine/impl/history/producer/DefaultHistoryEventProducer.java @@ -547,6 +547,7 @@ protected HistoricBatchEntity loadBatchEntity(BatchEntity batch) { // Implementation //////////////////////////////// + @Override public HistoryEvent createProcessInstanceStartEvt(DelegateExecution execution) { final ExecutionEntity executionEntity = (ExecutionEntity) execution; @@ -583,6 +584,7 @@ public HistoryEvent createProcessInstanceStartEvt(DelegateExecution execution) { return evt; } + @Override public HistoryEvent createProcessInstanceUpdateEvt(DelegateExecution execution) { final ExecutionEntity executionEntity = (ExecutionEntity) execution; @@ -620,6 +622,7 @@ public HistoryEvent createProcessInstanceMigrateEvt(DelegateExecution execution) return evt; } + @Override public HistoryEvent createProcessInstanceEndEvt(DelegateExecution execution) { final ExecutionEntity executionEntity = (ExecutionEntity) execution; @@ -690,6 +693,7 @@ protected void determineEndState(ExecutionEntity executionEntity, HistoricProces } } + @Override public HistoryEvent createActivityInstanceStartEvt(DelegateExecution execution) { final ExecutionEntity executionEntity = (ExecutionEntity) execution; @@ -744,6 +748,7 @@ public HistoryEvent createActivityInstanceMigrateEvt(MigratingActivityInstance a } + @Override public HistoryEvent createActivityInstanceEndEvt(DelegateExecution execution) { final ExecutionEntity executionEntity = (ExecutionEntity) execution; @@ -762,6 +767,7 @@ public HistoryEvent createActivityInstanceEndEvt(DelegateExecution execution) { return evt; } + @Override public HistoryEvent createTaskInstanceCreateEvt(DelegateTask task) { // create event instance @@ -775,6 +781,7 @@ public HistoryEvent createTaskInstanceCreateEvt(DelegateTask task) { return evt; } + @Override public HistoryEvent createTaskInstanceUpdateEvt(DelegateTask task) { // create event instance @@ -797,6 +804,7 @@ public HistoryEvent createTaskInstanceMigrateEvt(DelegateTask task) { return evt; } + @Override public HistoryEvent createTaskInstanceCompleteEvt(DelegateTask task, String deleteReason) { // create event instance @@ -819,6 +827,7 @@ public HistoryEvent createTaskInstanceCompleteEvt(DelegateTask task, String dele // User Operation Logs /////////////////////////// + @Override public List createUserOperationLogEvents(UserOperationLogContext context) { List historyEvents = new ArrayList(); @@ -840,14 +849,17 @@ public List createUserOperationLogEvents(UserOperationLogContext c // variables ///////////////////////////////// + @Override public HistoryEvent createHistoricVariableCreateEvt(VariableInstanceEntity variableInstance, VariableScope sourceVariableScope) { return createHistoricVariableEvent(variableInstance, sourceVariableScope, HistoryEventTypes.VARIABLE_INSTANCE_CREATE); } + @Override public HistoryEvent createHistoricVariableDeleteEvt(VariableInstanceEntity variableInstance, VariableScope sourceVariableScope) { return createHistoricVariableEvent(variableInstance, sourceVariableScope, HistoryEventTypes.VARIABLE_INSTANCE_DELETE); } + @Override public HistoryEvent createHistoricVariableUpdateEvt(VariableInstanceEntity variableInstance, VariableScope sourceVariableScope) { return createHistoricVariableEvent(variableInstance, sourceVariableScope, HistoryEventTypes.VARIABLE_INSTANCE_UPDATE); } @@ -859,6 +871,7 @@ public HistoryEvent createHistoricVariableMigrateEvt(VariableInstanceEntity vari // form Properties /////////////////////////// + @Override public HistoryEvent createFormPropertyUpdateEvt(ExecutionEntity execution, String propertyId, String propertyValue, String taskId) { final IdGenerator idGenerator = Context.getProcessEngineConfiguration().getIdGenerator(); @@ -903,22 +916,27 @@ public HistoryEvent createFormPropertyUpdateEvt(ExecutionEntity execution, Strin // Incidents ////////////////////////////////// + @Override public HistoryEvent createHistoricIncidentCreateEvt(Incident incident) { return createHistoricIncidentEvt(incident, HistoryEventTypes.INCIDENT_CREATE); } + @Override public HistoryEvent createHistoricIncidentUpdateEvt(Incident incident) { return createHistoricIncidentEvt(incident, HistoryEventTypes.INCIDENT_UPDATE); } + @Override public HistoryEvent createHistoricIncidentResolveEvt(Incident incident) { return createHistoricIncidentEvt(incident, HistoryEventTypes.INCIDENT_RESOLVE); } + @Override public HistoryEvent createHistoricIncidentDeleteEvt(Incident incident) { return createHistoricIncidentEvt(incident, HistoryEventTypes.INCIDENT_DELETE); } + @Override public HistoryEvent createHistoricIncidentMigrateEvt(Incident incident) { return createHistoricIncidentEvt(incident, HistoryEventTypes.INCIDENT_MIGRATE); } @@ -1078,10 +1096,12 @@ protected HistoryEvent createBatchEvent(BatchEntity batch, HistoryEventTypes eve // Job Log + @Override public HistoryEvent createHistoricJobLogCreateEvt(Job job) { return createHistoricJobLogEvt(job, HistoryEventTypes.JOB_CREATE); } + @Override public HistoryEvent createHistoricJobLogFailedEvt(Job job, Throwable exception) { HistoricJobLogEventEntity event = (HistoricJobLogEventEntity) createHistoricJobLogEvt(job, HistoryEventTypes.JOB_FAIL); @@ -1104,10 +1124,12 @@ public HistoryEvent createHistoricJobLogFailedEvt(Job job, Throwable exception) return event; } + @Override public HistoryEvent createHistoricJobLogSuccessfulEvt(Job job) { return createHistoricJobLogEvt(job, HistoryEventTypes.JOB_SUCCESS); } + @Override public HistoryEvent createHistoricJobLogDeleteEvt(Job job) { return createHistoricJobLogEvt(job, HistoryEventTypes.JOB_DELETE); } @@ -1124,6 +1146,8 @@ protected void initHistoricJobLogEvent(HistoricJobLogEventEntity evt, Job job, H JobEntity jobEntity = (JobEntity) job; evt.setJobId(jobEntity.getId()); + + System.out.println("In history id: "+ jobEntity.getId()); evt.setJobDueDate(jobEntity.getDuedate()); evt.setJobRetries(jobEntity.getRetries()); evt.setJobPriority(jobEntity.getPriority()); @@ -1169,6 +1193,7 @@ protected void initHistoricJobLogEvent(HistoricJobLogEventEntity evt, Job job, H evt.setFailedActivityId(jobEntity.getFailedActivityId()); evt.setExecutionId(jobEntity.getExecutionId()); evt.setProcessInstanceId(jobEntity.getProcessInstanceId()); + System.out.println("In history: "+ jobEntity.getProcessInstanceId()); evt.setProcessDefinitionId(jobEntity.getProcessDefinitionId()); evt.setProcessDefinitionKey(jobEntity.getProcessDefinitionKey()); evt.setDeploymentId(jobEntity.getDeploymentId()); diff --git a/engine/src/main/java/org/camunda/bpm/engine/impl/persistence/entity/JobEntity.java b/engine/src/main/java/org/camunda/bpm/engine/impl/persistence/entity/JobEntity.java index 922463aefaa..512488836b8 100644 --- a/engine/src/main/java/org/camunda/bpm/engine/impl/persistence/entity/JobEntity.java +++ b/engine/src/main/java/org/camunda/bpm/engine/impl/persistence/entity/JobEntity.java @@ -231,6 +231,7 @@ public Object getPersistentState() { persistentState.put("exceptionMessage", exceptionMessage); persistentState.put("suspensionState", suspensionState); persistentState.put("processDefinitionId", processDefinitionId); +// persistentState.put("processInstanceId", processInstanceId); persistentState.put("jobDefinitionId", jobDefinitionId); persistentState.put("deploymentId", deploymentId); persistentState.put("jobHandlerConfiguration", jobHandlerConfiguration); diff --git a/engine/src/test/java/org/camunda/bpm/engine/test/api/history/BatchHistoricDecisionInstanceDeletionTest.java b/engine/src/test/java/org/camunda/bpm/engine/test/api/history/BatchHistoricDecisionInstanceDeletionTest.java index e8fe59943df..89b2cb24dde 100644 --- a/engine/src/test/java/org/camunda/bpm/engine/test/api/history/BatchHistoricDecisionInstanceDeletionTest.java +++ b/engine/src/test/java/org/camunda/bpm/engine/test/api/history/BatchHistoricDecisionInstanceDeletionTest.java @@ -16,7 +16,6 @@ */ package org.camunda.bpm.engine.test.api.history; -import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; @@ -49,7 +48,6 @@ import org.camunda.bpm.engine.test.ProcessEngineRule; import org.camunda.bpm.engine.test.RequiredHistoryLevel; import org.camunda.bpm.engine.test.api.runtime.BatchHelper; -import org.camunda.bpm.engine.test.util.AssertUtil; import org.camunda.bpm.engine.test.util.ProcessEngineTestRule; import org.camunda.bpm.engine.test.util.ProvidedProcessEngineRule; import org.camunda.bpm.engine.variable.VariableMap; @@ -148,19 +146,6 @@ public void removeBatches() { ClockUtil.reset(); } - @Test - public void shouldCreateProcessInstanceRelatedBatchJobsForSingleInvocations(){ - // when - Batch batch = historyService.deleteHistoricDecisionInstancesAsync(decisionInstanceIds, null); - helper.executeSeedJob(batch); - - //then - //Making sure that processInstanceId is set in execution jobs #4205 - assertThat(helper.getExecutionJobs(batch)) - .extracting("processInstanceId") - .containsExactlyInAnyOrder(decisionInstanceIds.toArray()); - } - @Test public void createBatchDeletionByIds() { // when @@ -680,6 +665,7 @@ public BatchDeletionHelper(ProcessEngineRule engineRule) { super(engineRule); } + @Override public JobDefinition getExecutionJobDefinition(Batch batch) { return engineRule.getManagementService().createJobDefinitionQuery() .jobDefinitionId(batch.getBatchJobDefinitionId()) diff --git a/engine/src/test/java/org/camunda/bpm/engine/test/api/history/removaltime/batch/BatchSetRemovalTimeTest.java b/engine/src/test/java/org/camunda/bpm/engine/test/api/history/removaltime/batch/BatchSetRemovalTimeTest.java index adb96a1cde1..5d166744697 100644 --- a/engine/src/test/java/org/camunda/bpm/engine/test/api/history/removaltime/batch/BatchSetRemovalTimeTest.java +++ b/engine/src/test/java/org/camunda/bpm/engine/test/api/history/removaltime/batch/BatchSetRemovalTimeTest.java @@ -2864,8 +2864,6 @@ public void shouldSetExecutionStartTimeInBatchAndHistoryForDecisions() { .putValue("dayType", "Weekend") ).evaluate(); - HistoricDecisionInstanceQuery query = historyService.createHistoricDecisionInstanceQuery(); - Batch batch = historyService.setRemovalTimeToHistoricDecisionInstances() .absoluteRemovalTime(CURRENT_DATE) .byQuery(historyService.createHistoricDecisionInstanceQuery()) @@ -2882,11 +2880,6 @@ public void shouldSetExecutionStartTimeInBatchAndHistoryForDecisions() { assertThat(batch.getExecutionStartTime()).isEqualToIgnoringMillis(CURRENT_DATE); assertThat(historicBatch.getExecutionStartTime()).isEqualToIgnoringMillis(CURRENT_DATE); - - //Making sure that processInstanceId is set in execution jobs #4205 - assertThat(executionJobs) - .extracting("processInstanceId") - .containsExactlyInAnyOrder(query.list().stream().map(HistoricDecisionInstance::getId).toArray()); } } diff --git a/engine/src/test/java/org/camunda/bpm/engine/test/api/runtime/ModificationExecutionAsyncTest.java b/engine/src/test/java/org/camunda/bpm/engine/test/api/runtime/ModificationExecutionAsyncTest.java index 53162f65674..8ddb91e18c0 100644 --- a/engine/src/test/java/org/camunda/bpm/engine/test/api/runtime/ModificationExecutionAsyncTest.java +++ b/engine/src/test/java/org/camunda/bpm/engine/test/api/runtime/ModificationExecutionAsyncTest.java @@ -319,7 +319,7 @@ public void createModificationJobs() { assertEquals(currentTime, modificationJob.getDuedate()); assertNull(modificationJob.getProcessDefinitionId()); assertNull(modificationJob.getProcessDefinitionKey()); - assertNull(modificationJob.getProcessInstanceId()); +// assertNull(modificationJob.getProcessInstanceId()); assertNull(modificationJob.getExecutionId()); } diff --git a/engine/src/test/java/org/camunda/bpm/engine/test/api/runtime/SetVariablesBatchTest.java b/engine/src/test/java/org/camunda/bpm/engine/test/api/runtime/SetVariablesBatchTest.java index f714784ec05..65781ceb227 100644 --- a/engine/src/test/java/org/camunda/bpm/engine/test/api/runtime/SetVariablesBatchTest.java +++ b/engine/src/test/java/org/camunda/bpm/engine/test/api/runtime/SetVariablesBatchTest.java @@ -40,7 +40,6 @@ import org.camunda.bpm.engine.history.HistoricProcessInstanceQuery; import org.camunda.bpm.engine.history.UserOperationLogEntry; import org.camunda.bpm.engine.impl.util.ClockUtil; -import org.camunda.bpm.engine.management.JobDefinition; import org.camunda.bpm.engine.repository.Deployment; import org.camunda.bpm.engine.runtime.Job; import org.camunda.bpm.engine.runtime.ProcessInstanceQuery; From 17de676bc85da56cd4f2da3dba46a515dc5673d3 Mon Sep 17 00:00:00 2001 From: Yana Vasileva Date: Thu, 5 Sep 2024 20:46:10 +0200 Subject: [PATCH 10/10] fix --- .../bpm/engine/impl/batch/AbstractBatchJobHandler.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/engine/src/main/java/org/camunda/bpm/engine/impl/batch/AbstractBatchJobHandler.java b/engine/src/main/java/org/camunda/bpm/engine/impl/batch/AbstractBatchJobHandler.java index 0cdb9804944..9deade17313 100644 --- a/engine/src/main/java/org/camunda/bpm/engine/impl/batch/AbstractBatchJobHandler.java +++ b/engine/src/main/java/org/camunda/bpm/engine/impl/batch/AbstractBatchJobHandler.java @@ -22,6 +22,8 @@ import java.util.List; import java.util.Map; +import org.camunda.bpm.engine.impl.batch.externaltask.SetExternalTaskRetriesJobHandler; +import org.camunda.bpm.engine.impl.batch.job.SetJobRetriesJobHandler; import org.camunda.bpm.engine.impl.batch.removaltime.DecisionSetRemovalTimeJobHandler; import org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl; import org.camunda.bpm.engine.impl.context.Context; @@ -176,7 +178,9 @@ protected void createJobEntities(BatchEntity batch, T configuration, String depl if (jobConfiguration.getIds() != null && jobConfiguration.getIds().size() == 1 && !(this instanceof DecisionSetRemovalTimeJobHandler) && !(this instanceof DeleteHistoricDecisionInstancesJobHandler) -// && !(this instanceof DeleteHistoricDecisionInstancesJobHandler) + && !(this instanceof SetJobRetriesJobHandler) + && !(this instanceof SetExternalTaskRetriesJobHandler) +// && !(this instanceof BatchSetRemovalTimeJobHandler) ) { job.setProcessInstanceId(jobConfiguration.getIds().get(0)); }