Disable transactional integrity inside process / subprocess


#1

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


#2

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


#3

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


#4

Any issues with doing the aync setting on the tasks?


#5

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


#6

What are you using CurrentUser for? (specifics)


#7

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);
};

#8

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


#9

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


#10

So this is the current Assignee of the task?


#11

Yes, you are right


#12

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?


#13

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!


#14

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()


#15

Thanks Stephen!