cancel
Showing results for 
Search instead for 
Did you mean: 

Question considering process correlation

parcus
Champ in-the-making
Champ in-the-making
Hi,

I'm working with activiti in a small group at a university and we have some issues with the way that processes can be found given some information to look for. Our project is about creating a game like monopoly that is executing based on activiti processes.

The situation:
We have a big process that acts as a game loop with a lot of call activities to keep it as structured as possible. One instance of the game is generelly identified by a Guid. Now it happens that the client sends a message to the server. That message contains the game's Guid and we want to find the corresponding and currently active process instance. When I say active I'm talking about the process that currently is doing the work, so in a lot of cases thats not the game loop process but some call activiti that was once startet in the game loop (running in sequence, not parallel).

The problem:
How to correlate between execution and the game's Guid or in detail, what is the smartest/fastest way to do it?
Until now it works when we are using signals and can query for executions waiting for a specific signal, but the performance is really bad, considering we have a query for each signal that is used and each time we have an incoming message. Using the business key for the top-level process (the game loop) did not really help, as it seems you only get exactly that process and not the currently active call activiti.

If you have a good solution to that, please tell me.

Further questions:
The problem kind of arises as i was not able to find proper definitions and descriptions (how they behave etc.) of business key, process instance id and execution id.
How do i handle call activities when using business keys? What is the difference between process instance id and execution id? As far as i understand a process instance is an execution, but why would i rather want the process instance than the execution?

I would be really glad if some person with more insight could help. Thanks in advance
1 REPLY 1

frederikherema1
Star Contributor
Star Contributor
Use the business-key to correlate between an unique ID and a process-instance. When starting the process, you can pass that in. Afterwards, you can query for the process-instance OR child-executions using executionQuery.processInstanceBusinessKey(…).

A process-instance is indeed an "execution", it's the ROOT execution for a running process. When a process splits into 2 parallel paths or needs a sub-scope (e.g.. subprocess), one or more child-executions are created. These executions reference the process-instance. On a ProcessInstance object, you can get the "process definition id", on an execution, you can't do this directly (can be done using the process-instance-id however). The business-key is a globally UNIQUE identifier YOU can give to a certain process. This key is not used by activiti, this uses the internal ID's. The business-key allows you to lookup a process-instance based on some key your business uses (hence the term).

In case of call-activities, you'll have a process-instance for your main process (game loop) and one for your call-activity. Potentially, there are more executions in between them, depending in the type of process.

Hopes this helps.