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

defer() does not trigger bounded timer event in parallel call activity with more than one instance #91

Open
ykoitzsch opened this issue Jun 22, 2022 · 1 comment

Comments

@ykoitzsch
Copy link

Process: A call activity runs multiple instances of a sub-process with a bounded timer event.

process_with_callactivity

What works: If only a single instance (loop cardinality = 1) is used, the timer works as intended (defer() time > timer) and the process enters the "inform boss" branch

What does not work: If 2 instances (loop cardinality = 2) are used, the timer does not trigger on a defer() that "takes too long" and the process never enters the "inform boss" branch

Doing the same with a) embedded subprocesses does work or b) doing it with "plain" camunda-bpmn-assert.

See attached project for tests: ProcessEngineTest & ProcessScenarioTest, they are more or less identical, once written using platform-scenario, once written use camunda bpmn assert only.

process_with_subprocess

Is defer() used wrong here or is there same issue with the timer?

timed-camunda-scenario-issue.zip

@rweisleder
Copy link

The essence of this issue is that in the test code the following construct is used:

ProcessScenario scenario = mock(ProcessScenario.class);
ProcessScenario subScenario = mock(ProcessScenario.class);
when(scenario.runsCallActivity("CallWork")).thenReturn(Scenario.use(subScenario));

This means that the same scenario (as in "same Java object") is returned each time the call activity is called. In this example, the call activity is called twice. Due to the parallel execution, both instances will get mixed up.

To fix the issue, you need to change the construct to:

ProcessScenario scenario = mock(ProcessScenario.class);
ProcessScenario subScenario = mock(ProcessScenario.class);
when(scenario.runsCallActivity("CallWork")).thenAnswer(invocation -> Scenario.use(subScenario));

See also #92

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants