Data Coherence for completing user task and updating external DB

Hello we use camunda as REST service in our app.
For completing user task in our app we use next code:

completeUserTask(String taskId, SpecificTaskData userData) {
     dao.update(userData)
     camundaRestApi.completeUserTask(taskId)
}

But this operation is not transactional.

I see two avaliable solution:
image

But i don’t like the idea creating service task or message receiver for each user tasks.
I think it makes a diagram unclear (more irrational).
What do you think about this problem? Thank you.

hi @neki,

you can introduce a new data service on the server side which combines the taskService.complete() and saves the user data into your business database. Here you can use the Spring or JEE transaction to reach your goal.

Hope this helps, Ingo


Ok, suppose that next code run in JEE transaction.

completeUserTask(String taskId, SpecificTaskData userData) {
     camundaRestApi.completeUserTask(taskId)
     dao.update(userData)
}

If camundaRestApi.completeUserTask(taskId) was successful and dao.update(userData) was fail - we have data mismatch.


Another case looks more correct:

completeUserTask(String taskId, SpecificTaskData userData) {
     dao.update(userData)
     camundaRestApi.completeUserTask(taskId)
}

But if next task (service task for example) needs data created in dao.update(userData) he could not get it because transaction will still not finish

Hi @neki,

you could not use the REST API to get a transaction, since HTTP Protocol cannot be rolled back.

You have to use the JAVA-API in the same server (typically a JEE Server) for both updates:

taskService.complete(userTaskId, variables);
dao.update(userData);

Hope this helps, Ingo

Thank you!
We knew this option.
Now we use EJB-remote where is working distributed transactions.
We were just trying to find a way to do this using REST