Camunda expanded Subprocess variable scope and message starts (and transaction boundaries)


the question first, because the latter explanation is maybe a bit confusing…
Is it possible that a subprocess has its own variable scope?

I have a sub process where the main activity is done and a Multiple Call activity is invoked. This Call activity gets some variables passed which are necessary for execution.

Inside this sub process, I have a further expanded subprocess which is holding a message driver Start (non-interupting) node which should start several “latecomers”. I can pass some variables with the message which are saved in the main process. Therefore, if I invoke this message several times, it is overwriting the values of the previous invocation, because the variables are set in the same scope.

I haven’t found any configuration for “sub process or token scopes”. Is it at least possible to identifier the “token” which was invoked by the message, so that I can emulate the “new token scope”?

I cannot setup a completely new process with it own scope, because I need the execution token in the upper subprocess to identify if this latecomer is also done.

Best Regards,

I have added a screenshot of a the related part in our BPM. Actually I want to have some user tasks between “Taskprocessing” the message start, but variables which are passed by REST message deliver call should be saved local and not in the process instance scope…

Currently, my approach is to directly call the Sub task in the call activity, because I hope that at least while being in one Transaction I can be sure that the variable is not overwritten by other message calls. But, I don’t know if I am right here as is it depends on what Camunda is locking during this transaction. I believe the process instance is locked and no other “token” can move while other is currently moving. Would be nice if someone could confirm this

Hi Michael,

You can use the setVariableLocal of the runtimeservice API for your case to set the variable in the scope of a sub process.

  // execution -> sub process execution

Hope this helps.


Hi Deivarayan,

maybe I should mention that I am using REST service for the message delivery:

So, I invoke HTTP POST: …/message

{"messageName" : "aMessage",
"businessKey" : "aBusinessKey",
"correlationKeys" : {
    "aVariable" : {"value" : "aValue", "type": "String"}
"processVariables" : {
    "aVariable" : {"value" : "aNewValue", "type": "String"},
    "anotherVariable" : {"value" : true, "type": "Boolean"}

Is it possible to set a variable as local variable there? If I want “anotherVariable” to be available only for the token which is responsible for the non-interupting message what is necessary to set?

It is merely like a “Thread local variable” in Java, a “token local variable” …

Best Regards,

Hi all,

my answer might be a bit late but maybe it helps someone else.

I also had this kind of challenge with a message-started event sub process.
I solved it using a TaskExecutionListener on the message start event. This listener converts a non-local variable to a local one.

public void notify(DelegateExecution execution) throws Exception {
    Object tmp = execution.getVariable("anotherVariable");
    execution.setVariableLocal("anotherVariable", tmp);