Manually set parent instance when process instance is started?

Hi folks,

I have a process, which is able to invoke different sub-processes. Since I am in a decoupled microservice environment, where the processes can live in different microservices, which run their own Camunda instances, the process does not use call activities, but it publishes an event to an event bus, which is consumed by a random other microservice, where the child process instance is started.

If the microservice, which runs the child process, is the same, which runs the parent, I would like to link the two processes, so that the child process appears as a called process instance of the parent one, eventhough there is no call activity in the process model.

Is there any way to achieve this, e.g. by manually setting the parent process instance when I start the child process instance using the Java API?

Cheers,
Stefan

Hi Stefan,

I am afraid that is not possible and I don’t think it should be. The link is for example used to propagate error events, which would be incorrect behavior in case of losely coupled processes. Instead, you could think in the direction of using process variables and writing a Cockpit plugin that links to process instances based on those variables (I assume you are after displaying the relationships in Cockpit). You could also consider having a dedicated variable type for variables that link to process instances, see https://github.com/ThorbenLindhauer/camunda-variable-serializers for an example (uses internal API). That could help filtering the relevant variables.

Cheers,
Thorben

1 Like

Hi Thorben,

thank you for your quick reply. Yes, I am after displaying the relationship in Cockpit.

I will look into your proposals and see what I can make out of it. If the child process is executed on a different microservice, we cannot monitor it in Cockpit anyway, so maybe we just live with it.

Cheers,
Stefan

@thorben

one more related question, maybe you can answer that as well.

I can start a process instance using RuntimeService::startProcessInstanceByKey where I can pass a caseInstanceId. Will the process instance be shown as called process instance of the respective case instance (maybe even if the process is not part of the case model)?

Cheers,
Stefan

Hi Stefan,

Honestly I don’t know. But I guess not. In the relational schema, there are two relevant properties in ACT_RU_EXECUTION: SUPER_CASE_EXEC_ and CASE_INST_ID_. I think the former is used to evaluate case parent-child relationships. And yet: If in doubt, try it out :wink:

Cheers,
Thorben