Skip to content

Commit

Permalink
[JBPM-10208] Signalling engine only once
Browse files Browse the repository at this point in the history
  • Loading branch information
fjtirado committed Nov 7, 2023
1 parent 2a809ac commit 5b8919f
Showing 1 changed file with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<RuntimeEngine> 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) {
Expand All @@ -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);
Expand Down Expand Up @@ -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 {}",
Expand All @@ -226,7 +234,6 @@ public void signalEvent(String type, Object event) {
}
}
if (!enginesToDelete.isEmpty()) {

currentlyActive.keySet().removeAll(enginesToDelete);
}
}
Expand Down

0 comments on commit 5b8919f

Please sign in to comment.