Skip to content

Commit

Permalink
[7.67.x-blue] [JBPM-10208] Signalling engine only once (#2360)
Browse files Browse the repository at this point in the history
* [JBPM-10208] Signalling engine only once (#2359)

* [JBPM-10208] Signalling engine only once

* [JBPM-10208] Alternative approach

* Revert "[JBPM-10208] Alternative approach"

This reverts commit 44b1751.

* Update PerProcessInstanceRuntimeManager.java

---------

Co-authored-by: Francisco Javier Tirado Sarti <[email protected]>
  • Loading branch information
github-actions[bot] and fjtirado authored Nov 20, 2023
1 parent 2de463b commit 4eb99eb
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 4eb99eb

Please sign in to comment.