External-task REST API, input/output mappings and local variables

Hi,

I’m building a process that revolves arround external service tasks that will be executed by other components through the external-task REST API.

In order to isolate the work, I’m using input/output mappings on every task. The input mappings works fine. As for the output mappings, although they execute correctly, the variables created by the external service task end up in process scope, not on the task’s scope.

That’s a big problem, because that would mean that the tasks could inadvertedly alter some of my global state. Is there a way to force variables created by the /external-task/{id}/complete API to be scoped locally rather than globally?

Best regards,
Carlos Jourdan

Looking at the javadoc, it seems that the complete() method of the ExternalTaskService states that the variables are created on a non-local scope. What is the reasoning behind this design?

Parameters:
externalTaskId - the id of the external to complete
workerId - the id of the worker that completes the task
variables - a map of variables to set on the execution (non-local) the external task is assigned to

Hi @carlosjourdan,

normally you want to use the results of a service call in one of the following activities. So they should survive the service call.

Hope this helps, Ingo

Hi @Ingo_Richtsmeier, they should survive, but after being correctly mapped from the variables returned by the service call into global variables available for all activities. Otherwise, I cannot properly implement external services with a local scope.

Hi,

Any idea if this is supported or will be supported? I agree with @carlosjourdan that the variable should only be global when you put it in the Output mapping. I think it should be by default local-scope or have an option when completing a task to specify 2 fields (variables and localVariables) wherein:

variables - any variables in this field will be global scope
localVariables - any variables in this field will only be in the scope of that task (local)

Hi @jhenebora, https://app.camunda.com/jira/browse/CAM-8607 implements the localVariables solution.

1 Like