diff --git a/jbpm-runtime-manager/src/main/java/org/jbpm/runtime/manager/impl/PerProcessInstanceRuntimeManager.java b/jbpm-runtime-manager/src/main/java/org/jbpm/runtime/manager/impl/PerProcessInstanceRuntimeManager.java index be011914de..dd46edd7c1 100644 --- a/jbpm-runtime-manager/src/main/java/org/jbpm/runtime/manager/impl/PerProcessInstanceRuntimeManager.java +++ b/jbpm-runtime-manager/src/main/java/org/jbpm/runtime/manager/impl/PerProcessInstanceRuntimeManager.java @@ -166,11 +166,13 @@ public void signalEvent(String type, Object event) { // first signal with new context in case there are start event with signal KieSession signalSession = null; + Set signalledEngines = new HashSet<>(); RuntimeEngine runtimeEngine = getRuntimeEngine(ProcessInstanceIdContext.get()); try { // signal execution can rise errors signalSession = runtimeEngine.getKieSession(); signalSession.signalEvent(type, event); + signalledEngines.add(runtimeEngine); } finally { // ensure we clean up if(signalSession!=null) { @@ -185,7 +187,10 @@ public void signalEvent(String type, Object event) { runtimeEngine = getRuntimeEngine(ProcessInstanceIdContext.get(Long.parseLong(piId))); try { // signal execution can rise errors - runtimeEngine.getKieSession().signalEvent(type, event); + if (!signalledEngines.contains(runtimeEngine)) { + runtimeEngine.getKieSession().signalEvent(type, event); + signalledEngines.add(runtimeEngine); + } } finally { // ensure we clean up disposeRuntimeEngine(runtimeEngine); @@ -215,8 +220,11 @@ public void signalEvent(String type, Object event) { if (context != null && context instanceof ProcessInstanceIdContext && ((ProcessInstanceIdContext) context).getContextId() != null) { try { - engineImpl.getKieSession().signalEvent(type, event, - ((ProcessInstanceIdContext) context).getContextId()); + if (!signalledEngines.contains(engineImpl)) { + engineImpl.getKieSession().signalEvent(type, event, + ((ProcessInstanceIdContext) context).getContextId()); + signalledEngines.add(engineImpl); + } } catch (org.drools.persistence.api.SessionNotFoundException ex) { logger.warn( "Signal event cannot proceed because of session not found exception {} for engine {}", @@ -226,7 +234,6 @@ public void signalEvent(String type, Object event) { } } if (!enginesToDelete.isEmpty()) { - currentlyActive.keySet().removeAll(enginesToDelete); } }