hi there, i know this is not regular use case but i try to model a process which processes a lot of data.
first the process “process data1” and if some data is broken it sets a process variable so the “check something” gate will pop up the usertask for repairing the corrupt data. at the same time the parallel gateway processes the data which has no errors. the happy case would be that the user repairs the broken data and after completing the user task the servicetask process data1 determines that the data is not broken anymore and passes it over to the process data2.
example process
the tricky case is that lets assume that we have already two executions of that process: one is at repair data2 and the first one is at repair data1. when repair data1 is completed the process data1 determines that everything is fine and passes the data to process data2. but process data2 now detects that something is not fine. remember the other execution of this process is already at the usertask repair data2. i dont want to start a second usertask. instead i want my process to detect it on the fly and skip the creating of the second (equal) usertask. well, actually at that point it only makes sense to me to close all unnecessary executions because the executions are at the same point/state.
-
im not quite sure where to place this? should i place the code in the java class or should i override the method parseUserTask of BpmnParse? i usually choose expression as implementation of servicetask and provide a java class e. g. ExampleServiceDelegate
-
how to reach that behaviour. i think ProcessInstanceModificationBuilder is the way to go? something like the following snippet but im not sure what “cancelAllForActivity” will do. does it also suspend the execution of that activity?
ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().singleResult();
runtimeService.createProcessInstanceModification(processInstance.getId())
.cancelAllForActivity(“repair data”)
.execute();
- your documentation says “Process instance modification within the same instance is not recommended! An activity which tries to modify its own process instance can cause undefined behavior, which should be avoided.” - in my case this means i should not suspend the execution which determines that there is already a usertask but the other one?
i looked up some other topics related to the ProcessInstanceModificationBuilder but didnt find any solutions for myself. im open for advices if there is a better way to go. thank you.