Skip to content

Commit

Permalink
[JBPM-10208] Alternative approach
Browse files Browse the repository at this point in the history
  • Loading branch information
fjtirado committed Nov 8, 2023
1 parent 5b8919f commit 0dd963e
Showing 1 changed file with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -166,13 +166,12 @@ 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<>();
Set<Long> 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 @@ -184,12 +183,13 @@ public void signalEvent(String type, Object event) {
// next find out all instances waiting for given event type
List<String> processInstances = ((InternalMapper) mapper).findContextIdForEvent(type, getIdentifier());
for (String piId : processInstances) {
runtimeEngine = getRuntimeEngine(ProcessInstanceIdContext.get(Long.parseLong(piId)));
long processInstanceId = Long.parseLong(piId);
runtimeEngine = getRuntimeEngine(ProcessInstanceIdContext.get());
try {
// signal execution can rise errors
if (!signalledEngines.contains(runtimeEngine)) {
if (!signalledEngines.contains(processInstanceId)) {
runtimeEngine.getKieSession().signalEvent(type, event);
signalledEngines.add(runtimeEngine);
signalledEngines.add(processInstanceId);
}
} finally {
// ensure we clean up
Expand Down Expand Up @@ -220,10 +220,10 @@ public void signalEvent(String type, Object event) {
if (context != null && context instanceof ProcessInstanceIdContext
&& ((ProcessInstanceIdContext) context).getContextId() != null) {
try {
if (!signalledEngines.contains(engineImpl)) {
engineImpl.getKieSession().signalEvent(type, event,
((ProcessInstanceIdContext) context).getContextId());
signalledEngines.add(engineImpl);
Long processInstanceId = ((ProcessInstanceIdContext) context).getContextId();
if (!signalledEngines.contains(processInstanceId)) {
engineImpl.getKieSession().signalEvent(type, event, processInstanceId);
signalledEngines.add(processInstanceId);
}
} catch (org.drools.persistence.api.SessionNotFoundException ex) {
logger.warn(
Expand Down

0 comments on commit 0dd963e

Please sign in to comment.