Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.

Bug 1213209

Summary: Duplicate Timer calls by a Boundary Timer inside a MultipleInstances
Product: [Retired] JBoss BPMS Platform 6 Reporter: Toshiya Kobayashi <tkobayas>
Component: jBPM CoreAssignee: Shelly McGowan <smcgowan>
Status: CLOSED EOL QA Contact: Radovan Synek <rsynek>
Severity: high Docs Contact:
Priority: unspecified    
Version: 6.1.0CC: mbaluch
Target Milestone: DR1   
Target Release: 6.2.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
: 1226107 (view as bug list) Environment:
Last Closed: 2020-03-27 20:03:40 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1226107    
Attachments:
Description Flags
BPMN2-BoundaryTimerInMultipleInstances.bpmn2.workaround none

Description Toshiya Kobayashi 2015-04-20 03:32:50 UTC
Description of problem:

Platform BZ for https://issues.jboss.org/browse/JBPM-4611


Steps to Reproduce:
1. See a PR https://github.com/droolsjbpm/jbpm/pull/248

Actual results:

"Email Notification" is triggered 9 times at a time.

Expected results:

"Email Notification" is triggered 3 times at a time.

Comment 1 Toshiya Kobayashi 2015-04-20 04:55:30 UTC
Created attachment 1016219 [details]
BPMN2-BoundaryTimerInMultipleInstances.bpmn2.workaround

Comment 2 Toshiya Kobayashi 2015-04-20 05:01:23 UTC
Attached a process which tries suppress the duplicate calls. A problem is that it would be cumbersome when we have many Timer+Notification pairs in a process so needs to have a unique 'key' for each Notification.

===============================
[Prepare]
java.util.Map map = new java.util.HashMap();
kcontext.setVariable("notificationMap", map);

...

[Email Notification]
// Suppress duplicate calls
java.util.Map map = (java.util.Map)kcontext.getVariable("notificationMap");
String key = "EmailNotificationForTask1-" + kcontext.getVariable("actorName");
Object value = map.get(key);
long current = System.currentTimeMillis();
if (value != null) {
    long lastNotification = Long.parseLong((String)value);
    if ((current - lastNotification) < 1000) {
        // do nothing
        return;
    }
}
map.put(key, String.valueOf(current));
kcontext.setVariable("notificationMap", map);

// Send an email
...

Comment 3 Toshiya Kobayashi 2015-04-20 05:09:04 UTC
Note: this workaround just suppresses duplicate calls in the Script Task so it doesn't solve the assert failure of the test case GlobalTimerServiceBaseTest.testTimerInMultipleInstances() because it counts ProcessEventListener.afterNodeLeft() of "timer", which is still actually fired even with the workaround.

Comment 4 JBoss JIRA Server 2015-04-29 15:15:12 UTC
Marco Rietveld <marco.rietveld> updated the status of jira JBPM-4611 to Resolved

Comment 6 Marco Rietveld 2015-04-30 08:53:30 UTC
Leaving this as assigned since the BZ is for 6.2 and could be included in a future roll-up?

Comment 9 Tomas Livora 2015-11-09 13:50:06 UTC
Verified on BPMS 6.2.0 ER5

https://github.com/droolsjbpm/jbpm/pull/327