Search process instances by variable

Hello everyone. Is there a way (and if so how does the way look like) to check if there is a process instance running with a certain variable and value. I want to check this from my code before I start a new process instance. I use camunda 8.

Hello @MaartenvV ,

there is an endpoint in the Operate API that could serve: Operate API (REST) | Camunda Platform 8 Docs

Anyway, Zeebe has a very nice mechanism: Message Cardinality using the Correlation Key on Start Events:

This allows you to ensure that only one process instance containing the correlation key is active at a time.
Important: Setting TTL to 0 will make the message live forever as soon as it was correlated (like an event in a queue).

I hope this helps

Jonathan

great, thanks! I have tried it out and it solved by problem! However I have question: you do not have to specify the correlation key on the start event, how does it know which variable is the correlation key?

Hello @MaartenvV ,

the correlation key does not necessarily rely on a process variable. Instead, it is a correlation concept that requires a simple string.

A message start subscribes to messages without knowledge about the concrete message correlation key that will come (as there is no direct relation to an active process instance).

Then, the logic on how message start events handle correlation keys is applied. This means that the engine at some point knows which process instances are running with which correlation key. Not as process variable, but “directly”.

I hope this helps

Jonathan

Hi Jonathan,

Thanks for the explanation (and so quick), it really helps!

Regards,

Maarten

1 Like

Hi Maarten,

I had a similar topic.

Following query was working on my side:

Bernd

2 Likes