Using Distributed Transactions using Rest API

We have integrated the Camunda Rest API into our Asp.Net MVC framework. In addition to the work of Camunda itself, we save some data in the database. There was a problem related to the fact that in case of errors, we have data desynchronization in Camunda and the database, because. on error, the database is rolled back, but Camunda is not. Using the Spring Camunda library is not possible for us, because the project is written in .Net framework. Are there any solutions for our problem? Are there any plans to address them?
Thanks for the help.

Hey @MiXaiL ,

I just want to make sure I understand it correctly: You have a database for Asp.Net and Camunda’s database. If an error occurs the database for Asp.Net is rolled back. In Camunda’s DB there is a rollback too but the last transaction point of the DB of Camunda is not matching with the one of the Asp.Net database?
Does the error occur in an External Task worker and is communicated back as an incident to the Camunda engine?
Maybe you could solve the logic in your process model using compensation events. Instead of sending a failure to Camunda, you could send a bpmn error and catch the bpmn error in your process model in an event subprocess, which then triggers compensation.
Not sure if that would solve your problem?
Cheers
Nele

A way to address Rollbacks in your process model would be the usage of compensation events.

It is not possible with the Rest API to report an error to the Camunda mechanism. We cannot generate errors using the Rest API.

Hey @MiXaiL ,

Yes you can report failure to the process engine using REST. If you are working with external tasks you can report a failure or a bpmn error.
If you use .Net I assume you use External task right?
Cheers
Nele

Sorry I was wrong, it is indeed possible to throw exceptions in the Rest API.
Example: Our system stores the status of each of the tasks in a process. We have closed the user task, we must somehow fix this moment in our database, but in the process of saving the state, we get an exception. Those. we have not fixed these changes in the database, but they have been fixed in Сamunda. I hope now I was able to explain the problem in more detail.

Hey @MiXaiL ,

not really sure if I understand it correctly: You complete a user task in Camunda: In Camunda there is no exception. So from point of the Camunda engine’s view everything is fine and the process should continue.
In another database you want to store the completion of the user task too. But in that database they could occur an error while saving. In that case the database does not contain the correct state.

So you want to rollback the user task in Camunda and the user has to fill in the information again?

Maybe it could work if you define a service task for saving the state of the user task in the other database. This way if the external task fails it can report the failure to Camunda as well and you know that the other database has not the correct state of the completed user task?

Cheers
Nele

it doesn’t fit our business logic. The client wants to create a BPM project, in which, for each user task, he specifies the performer and the conditions for performing this task. The conditions for completing the task and the executor are stored in the database. The client should not think about whether we will have a problem when saving data to the database and take this into account in the project scheme. The only solution I currently see is using a distributed transaction, which is not supported through the Rest API. A common transaction for two databases, which is rolled back in case of an error while saving data.