Difference between Execution.setVariable(name, value) and RuntimeService.setVariable(executionId, name, value))

Hello,

I would like to know the difference between Execution.setVariable(name, value) and RuntimeService.setVariable(executionId, name, value). Do they work differently under the hood or they can be used interchangeably?

Thanks.

Hi @cambarantama
Internally when you call RuntimeService.setVariable(executionId, name, value) the execution is loaded by the ID and the variable is then set on it.
So yes those two methods are doing exactly the same thing.

2 Likes

In addition to what @rohwerj writes, RuntimeService#setVariable is also an API entry point whereas Execution#setVariable can be only called from within Camunda delegation code where you have access to an Execution object (e.g. from a JavaDelegate).

2 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.