cancel
Showing results for 
Search instead for 
Did you mean: 

Output variables from CallActivity on BoundaryEvent trigger?

jonathan1
Champ in-the-making
Champ in-the-making
I have a call activity publishing an exit-code variable.  The call activity also has a boundary error event associated with it. 

After triggering the boundary event, I'd like to read the published exit-code variable in the parent process, but tracing the Activiti Engine, it appears that handling the boundary event preempts publishing the call activity's internal exit-code variable to the output variable, so the output variable isn't pushed out to the parent (it is set in the child process, looking at the DB).

Is there a way to ensure that the parent process can read a variable from it's child call activity in the event a boundary event is triggered?
24 REPLIES 24

mdaviot
Champ in-the-making
Champ in-the-making
Hi,

In my context, I also tried to do this. My interpretation of BPMN execution semantics is it should be possible to attach some date to an Error Event so this should be possible.

This is not supported yet by Activiti AFAIK.

To circumvent the issue, I defined a pattern from the design model (using sth like Bizagi) to the executable model (done with Activiti) which says to use instead of the Error Boundary Event in this case a return code, mapped in the subprocess call activity, and test it in a gateway right after the subprocess.

Regards
Michel

iam
Champ in-the-making
Champ in-the-making
I already post a solution to this problem: ACT-1411

jonathan1
Champ in-the-making
Champ in-the-making
Thanks, iam and mdaviot, for both the pattern reference and upload.

I decided to post the variable to the parent process and wait for another Activiti release to address writing to output variables on boundary events.

smirzai
Champ on-the-rise
Champ on-the-rise
Here is part of my comment I wrote ACT-1411  https://jira.codehaus.org/browse/ACT-1411

I am not sure, this is what is intended by specification. When an error occurs, it means that you were not able to do the job and output and variables are not valid. You can only send an error code to  let the caller know what was the problem.
If you need variable data to produce the error code, it might be a good sign that error handling code is not in a good place. Maybe you can move the error processor to the scope of the variables, process variables and throw the error with error code. Something like the figure with the annotation " error handler has access to variables local to the subprocess" in Event Sub-Process section of activiti guide.

mdaviot
Champ in-the-making
Champ in-the-making
Hi,

Here is also my next reply on the JIRA, I suggest to reopen it if you agree with this suggestion.


I agree with what was said before, ie that normal mapping should not occur when an Error Event is thrown in the subprocess.

However, I also had a deep look at the spec for BPMN :
http://www.omg.org/spec/BPMN/2.0/

In section 8.3.3, we see that the Error has an ItemDefinition which the same as the one used in figure to define the "payload" of a Message.

So my suggestion is to implement in Activiti a way to set for an error event this payload, by using the ItemDefinition class. This way the Error Event can have some data attached to it (same as the variables used for an Start Event message for instance), and this data can be used in the calling parent process to know some context information about the cause of the error.

Regards
Michel

jbarrez
Star Contributor
Star Contributor
I see the point in that. I don't know if itemDefinition is the best way to do it … maybe extending BpmnError is a better way.
If you need this, please file a Jira issue with a link to this forum post.

mdaviot
Champ in-the-making
Champ in-the-making
OK, I created a new JIRA for that :

https://jira.codehaus.org/browse/ACT-1462

mdaviot
Champ in-the-making
Champ in-the-making
From Saeid : Based on spec, could you propose a sample xml bpmn doing the job ?

Based on the spec, a BoundaryEvent is a CatchEvent and thus has a DataOutput and DataOuputAssociation.
I suggest to use something similar to the implementation of the WebserviceTask which also uses dataOutputAssociation.

See an example of such a BPMN file here : https://github.com/Activiti/Activiti/blob/master/modules/activiti-cxf/src/test/resources/org/activit...


I don't understand all of it yet, but I think this shares enough features to be used in the implementation of the BoundaryEvent in Activiti.

smirzai
Champ on-the-rise
Champ on-the-rise
Yes, I agree with your detailed analysis Saeid.
Something to take into account also is a ErrorEvent can be raised from within the Java code with the usage of the BpmnError exception. I suggest that this exception has a property of type Map to define the associated data.