Saving transaction between two transaction boundaries

I’m using Camunda with Springboot. I have a simplified version of my BPMN diagram to showcase the problem. I have two delegate executions as below.
sample.bpmn (3.8 KB)

Each delegate saves some information in the database and then makes an API call.
Now if the second API call fails and throws an error, the cockpit displays it and the information stored in the database is rolled back. I know that this is by design but we have other services that query the database. We need to be able to show them that an api call was attempted but it failed.

Is there any way to run this database update in a separate transaction and have it committed, no matter what happens with the API call?

Hi @karan.razdan,

just mark the second service task with “Asynchronous before”.

You can find more details on this topic here: Transactions in Processes | docs.camunda.org

Hope this helps, Ingo

Hi @Ingo_Richtsmeier, as far as I understand, the “Asynchronous before” will make sure that everything that has happened in the first task will be committed. But my issue is that I need some of the database changes that happen in the second task should to also be committed even if there is an error thrown in that task. I have already tried to get this behavior using the async before option but no luck.

Hi @karan.razdan,

as the transaction either commit or fail, you can either split your second service task into two (easy) or get into the topic of nested transactions (challenging).

Hope this helps, Ingo

Due to certain design limitations, it was not feasible to break the task up. So I went with the nested transaction path and it seems to work well. Thanks @Ingo_Richtsmeier!