Pass SuperProcessId of a manually started sub-process(using Java API)

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

Pass SuperProcessId of a manually started sub-process(using Java API)

Hello,

I have a two diagrams in my Activiti project.

The first of them has a ServiceTask which starts manually a sub-process instance, using the Activiti java API.

Here is snippet from the code:

runtimeService.startProcessInstanceById(processDefinitionId, context.getVariables()); - where the processDefinitionId is the id of the second diagram

This successfully starts a sub-process and everything works fine.

However, I want to pass the processId of the process which starts the new sub-process as a ParentId or as a SuperProcessId.

I used CallActivities in order to do that but now, I need to use the Java API as there are some issues with the parallel execution of the callActivities(sequential = false).

Could you tell me how can I do that and if it is possible at all?

Thanks,

Encho

2 Replies
warper
Established Member II

Re: Pass SuperProcessId of a manually started sub-process(using Java API)

Hi Encho!

Manual handling of super execution or parent execution references will not make the trick - you will end up with genuine subprocess/called activity if you manage to do it properly.

You can add super process id into variables map or set it as business for second process after creation.

gdharley
Intermediate

Re: Pass SuperProcessId of a manually started sub-process(using Java API)

I agree with Warper, your safest approach would be to add the parent process instance id as a variable and inject it when you start the "sub process".

You indicate you were having issues with the parallel execution of Called Activities, likely this is because you are hitting Optimistic Locking Exceptions if you are updating variables in the Called Activities. 

Check the following thread for details:
Synchronization issue in parallel multi-instance call activity 

Cheers,

Greg