Insert data to custom tables concurrently with Camunda tables insertion

When a process instance starts, running or finishes, the data and variables of the instance would be inserted to the Camunda tables.
I need to insert this data and variables into my own custom tables concurrently with the insertion of data to Camunda tables. but it should be done by Camunda Engine it self.
How to Identify my own tables to Camunda Engine?
own tables are beside Camunda tables.
I read lots of topics about custom queries and the examples but nothing help.

Hi @Mohammad_Hasan_Saffa,

usually you do this by adding either Java Delegate classes to service tasks (https://docs.camunda.org/manual/7.12/user-guide/process-engine/delegation-code/#java-delegate) or use listeners (https://docs.camunda.org/manual/7.12/user-guide/process-engine/delegation-code/#execution-listener).

In the execute() or notify() method you can use common JDBC programming to put the data where ever you need them.

Hope this helps, Ingo

Thank you @Ingo_Richtsmeier for your answer.

Java Delegate or Listeners are good answers, but I want that Camunda Engine do the relational queries for my custom tables too.

for example Camunda Engine insert some variables of process instance into the ACT_RU_VARIABLE table and into some another tables. beside of these insertions, do insert all those variables into my custom table too.

is there any way to identifying my custom tables to Camunda Engine for doing something like that?

Hi @Mohammad_Hasan_Saffa,

usually you won’t extend the persistence layer of the process engine for this.

But as the engine is open source, you can inspect the code in your IDE.

It’s a complicated task to hook into the persistence layer and you have to use internal APIs for this, which are not meant to be stable.

tl;dr: It may be possible, but you should not do it. Stay with the listener approach.

Hope this helps, Ingo

1 Like

@Ingo_Richtsmeier Surely I won’t trying to change engine.

so you mean:

  • The engine won’t do the insertion into my custom tables automatically.

  • If i need to save some required variables and data in all parts of process instance, i should save them manually with MyBatis or any other ways.

am i right?

1 Like

Hi @Mohammad_Hasan_Saffa,

yes.

1 Like

Hi @Mohammad_Hasan_Saffa I am trying to achieve the same using mybatis. I would really appreciate your help in that direction. How are the configurations for this
achieved?

Hi @Vedika

You’ve already posted this question here can you make sure not to duplicate questions, especially on topics that are over a year old. Thanks :slight_smile:
I’m going to lock this topic.