Disable transactional integrity inside process / subprocess

Dear Camunda community,

A couple of questions on error handling during process execution:

1/ By default after an error process “rolls-back” to a previous successful user-related transaction. Is there a way to change this behaviour and switch off transaction mode (so, stop at the last activity, even if it is a script or a connector)?

2/ I am looking for a pattern to implement similar behaviour (1) on a subprocess level as well: disable roll-back + stop subprocess execution

Thank you in advance.

Best regards,
Ilya

What’s your use case? As a very simple workaround: make all your tasks async which will make each task it’s own transaction.

Hi @StephenOTT,

The case is simple: I don’t want to model compensation logic in a process in case of failed transactions.

E.g I have a simple chain of activities:

1/ User input
2/ Connector sends data to ERP via SOAP
3/ … some further processing occurs (notifications, scripts, etc.)
4/ User input

In case I have an issue at step 3 system will roll-back to step 1. However, I already have an object in ERP created (step 2). I don’t want to void this object during roll-back compensation as object might already be processed by ERP to the stage where no easy way for compensation exist, so no real “compensation” is possible.

Best regards,
Ilya

Any issues with doing the aync setting on the tasks?

Hi @StephenOTT,

Just tested. Seems to work. I think the only issue would be a loss of CurrentUser() context.

Thank you so much!

Best regards,
Ilya

What are you using CurrentUser for? (specifics)

I pass CurrentUser() to formio submission object when create a form.

The workaround for the loss of a context (which happens for a subprocess anyway) would be to add a Task listener for an assignment event:

try {
    var current_user = task.execution.getProcessEngineServices().getIdentityService().getCurrentAuthentication().getUserId();
} 
catch (error) {current_user = ""} 
finally { 
      task.execution.setVariableLocal("current_user", current_user);
};

But what is “currentUser” for you? This is the Initiator of the process?

Nope, the one who actually opens the UserTask form for submission

So this is the current Assignee of the task?

Yes, you are right

okay, so you are using the currentUser inside of a execution listener for a Start Listener of the User Task?

Why cant you use the current Assignee value of the user task?

Nope I use it in Task listener for an assignment event. However I was not aware of a second way to retrieve this data. So will use. Thanks @StephenOTT for the suggestion!

So even better:

If you are in a Task Listener than you have the TaskDelegate:

https://docs.camunda.org/javadoc/camunda-bpm-platform/7.8/org/camunda/bpm/engine/delegate/DelegateTask.html#getAssignee()

So you can just do task.getAssignee()

Thanks Stephen!