Identify wait states by direct SQL database query

We have a large BPMN that contains various things, including:

  • user tasks
  • wait states: receive tasks, event-based gateways
  • non-wait states: service tasks, gateways etc…

We would like to be able to distinguish these three Camunda states by making direct a SQL JOIN to the Camunda database. Currently we have something like this:

WITH camunda_cte AS (
  SELECT
    business_key_ AS business_key,
    array_agg(DISTINCT task_def_key_) AS task_keys
  FROM (
      camunda.act_ru_execution
    INNER JOIN camunda.act_ru_task USING (proc_inst_id_)
  )
  GROUP BY business_key_
)
SELECT * FROM some_other_table
  INNER JOIN camunda_cte USING (business_key)

This allows us to identify when the process instance is in a user task (our BPMN only has one active user task at a time, but the SQL allows for more).

Is there a way to enhance this SQL to distinguish wait states from non-wait states?

Note 1: We use async-after with almost all elements in the BPMN.
Note 2: We use subprocesses, thus the wait state (but not user task) could be in a subprocess.

Thanks for any help!

Hi @Stephen_Colebourne,

I don’t have the SQL statement at hand.

But the table ACT_RU_TASK saves only user tasks. Everything else is in ACT_RU_EXECUTION.

Maybe the activity instance tree helps you further: Process Engine Concepts | docs.camunda.org

Hope this helps, Ingo