Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[7.67.x] [JBPM-10208] Signalling engine only once #2361

Merged
merged 3 commits into from
Nov 20, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading