From b94a0a5c43ad5fa11d9bb059c209ae595457ec52 Mon Sep 17 00:00:00 2001 From: Bas Claessen Date: Wed, 24 Jul 2024 09:13:39 +0200 Subject: [PATCH] In case of a timer event, only process event sub process when no timer job is present --- .../impl/dynamic/AbstractDynamicStateManager.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/dynamic/AbstractDynamicStateManager.java b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/dynamic/AbstractDynamicStateManager.java index 223e4361810..833b28d9b1b 100644 --- a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/dynamic/AbstractDynamicStateManager.java +++ b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/dynamic/AbstractDynamicStateManager.java @@ -657,13 +657,21 @@ protected void processPendingEventSubProcessesStartEvents(ProcessInstanceChangeS ProcessEngineConfigurationImpl processEngineConfiguration = CommandContextUtil.getProcessEngineConfiguration(commandContext); ProcessInstanceHelper processInstanceHelper = processEngineConfiguration.getProcessInstanceHelper(); EventSubscriptionService eventSubscriptionService = processEngineConfiguration.getEventSubscriptionServiceConfiguration().getEventSubscriptionService(); + ManagementService managementService = processEngineConfiguration.getManagementService(); for (Map.Entry pendingStartEventEntry : processInstanceChangeState.getPendingEventSubProcessesStartEvents().entrySet()) { StartEvent startEvent = pendingStartEventEntry.getKey(); ExecutionEntity parentExecution = pendingStartEventEntry.getValue(); + EventDefinition eventDefinition = startEvent.getEventDefinitions().isEmpty() ? null : startEvent.getEventDefinitions().get(0); - //Process event sub process when no subscriptions are found - if (eventSubscriptionService.findEventSubscriptionsByExecution(parentExecution.getId()).isEmpty()) { + //Process event sub process when no subscriptions/timer jobs are found + boolean processEventSubProcess = false; + if (eventDefinition instanceof TimerEventDefinition) { + processEventSubProcess = managementService.createTimerJobQuery().executionId(parentExecution.getId()).list().isEmpty(); + } else { + processEventSubProcess = eventSubscriptionService.findEventSubscriptionsByExecution(parentExecution.getId()).isEmpty(); + } + if (processEventSubProcess) { processInstanceHelper.processEventSubProcess(parentExecution, (EventSubProcess) startEvent.getSubProcess(), commandContext); } }