Transfer whole DelegateExecution to a sub-process using CallActivity

cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Member II

Transfer whole DelegateExecution to a sub-process using CallActivity

Hello,

I have a process diagram that contains of a lot of variables which are persisted in the DelegateExecution. 

This diagram reaches a callActivity which trasfers the execution to a new process diagram which needs almost all of the variables from the first diagram. The variables from the first diagram are passed by the callActivity(I have used the following tutorial: Activiti User Guide -  section 8.6.4. Call activity (subprocess)). There in the InputVariables tab of the MainConfig of the CallActivity, I have placed all the variables which need to be transfered.

However, this is too much for reading and easy to mistake with some of the variables.

My question is, can I somehow transfer the whole DelegateExecution from the first diagram to the second one without transfering each variable one by one?

P.S. I do not want to use sub-process as I want my diagrams to be reused on several places. That is why I want to use CallActivity

Thanks and best regards,

Encho

3 Replies
Highlighted
Intermediate

Re: Transfer whole DelegateExecution to a sub-process using CallActivity

I would not recommend you pass the entire execution context into the sub process as the execution context includes much more than just the task and process variables.
Instead, I suggest you collect the variables into a list or array and pass them into the sub-process that way.

You can collect the variables in an executionListener by calling execution.getVariables(), this will return a map of the variables in the execution, you can then assign this list to a local (task scoped) variable that you set as an input to the called activity.

This way, the task local variable disappears as soon as you return from the called activity and you aren't passing in more than you need to the called activity.

Hope this helps,

Greg

Highlighted
Member II

Re: Transfer whole DelegateExecution to a sub-process using CallActivity

Hello,

What if the variables from the DelegateExecution contain byte arrays and other big data in it?

Will this take twice of the space in the database, if I put everything in a variable and pass it to the callActivity?

Thanks and best regards,

Encho

Highlighted
Intermediate

Re: Transfer whole DelegateExecution to a sub-process using CallActivity

Ummm, you were originally planning on passing in the entire execution context which would contain the same content as well as a bunch of other stuff (scriptEngine references, process definition etc).

Using the method I proposed, you could easily filter the variable list to include only the bytearray id for pojo's and binary data.
Keep in mind, called activities are individual stand alone process instances, they have their own execution sack and set of variables (i.e.not shared with parent).

Greg