AnsweredAssumed Answered

Activiti 5.22: Message-Cancelled Call Activity doesn't fire subprocess PROCESS_CANCELLED

Question asked by willb on Aug 29, 2018
Latest reply on Sep 13, 2018 by willb

(Title originally indicated v5.18, but we are on 5.22).

 

When a process instance ends via an end event a PROCESS_COMPLETE listener event fires.  If the process hits a terminate end event PROCESS_CANCELLED fires.

 

When that subprocess is the result of a Call Activity and the Call Activity receives a boundary message, placed on top of the element in the Eclipse designer, the subprocess does indeed get killed off, but as best I can tell, the PROCESS_CANCELLED event doesn't fire.

 

Has anyone else run into this?  How did you solve it?  The problem for my company is that we have to keep our legacy system in sync with the Activiti workflow and orchestration.  Certain subprocesses are "orders" and when we instantiate those subprocesses, we have a matching task in our legacy system.  That "task" for us isn't a real task, its more of a "task container".  When the order process starts, we go to our internal API, create the matching wrapper, get our unique id, then store that ID as a process variable on the order subprocess.

 

Whenever that process ends, we have to tell the API "Hey, we're done.  Here's the 'completeTaskEventTrackingId' you gave me earlier...close it."  For us, if the process ends gracefully, we close that task in the legacy system as "Completed".  If it terminates, we marked it as "Cancelled".   This all works just fine, unless the process is terminated by terminating it's parent Call Activity!  Since the listener point doesn't fire...we have no way to know it's over and grab that subprocess variable to handle it.  Interestingly, any open tasks in that subprocess DO fire the ACTIVITY_CANCELLED with a type of userTask.  And so do other callActivity types.  My conclusion is that this is a 5.18 bug.  Unless it's by design?  If so, why?

 

Let me note here, that this IS indeed a cancel event:

<boundaryEvent id="boundarymessage1" name="Message" attachedToRef="callActivity1" cancelActivity="true">
     <messageEventDefinition messageRef="testKillMessage"></messageEventDefinition>
</boundaryEvent>

After hours of trying to solve this, I came up with another potential solution but, in the end, could not make it work.  Since the ACTIVITY_CANCELLED fires for the Call Activity (element), okay...I'll just grab the process variables from the subprocess that it instantiated.  We know when the subprocess ends, that the Call Activity that fired it is completed and flow moves on to the next element.  Somehow the parent process' Call Activity is linked to the subprocess instantiation to enable this natively.  But, while there are 4000 questions online about how to get the parent process ID from the child process...how do you go the other way?  How does one ask "I have this Call Activity...what was the processInstanceId of the subprocess?"

 

I've struggled with this for days.  I'm not a Java guy, but a decent programmer.  I can explore Javadocs with the best of us, and using Eclipse really helps me on the object class insights.

 

I could really use some help.

 

The end goals are any of the following:

  • How to get the PROCESS_CANCELLED to fire for the subprocess instance when the Call Activity is terminated?
  • How to determine the sub-processInstanceId spawned by the Call Activity in the parent process?

 

Eagerly awaiting some insight from others.

Outcomes