Input/Output Variable Mapping

Hi All,

According to the doc:

To improve the reusability of source code and business logic, Camunda BPM offers input/output mapping of process variables. This can be used for tasks, events and subprocesses.

I think it is great idea, thanks a lot to support it!

However it doesn’t work for a Task.

Caused by: org.camunda.bpm.engine.ProcessEngineException: ENGINE-09005 Could not parse BPMN process. Errors: 
* camunda:inputOutput mapping unsupported for element type 'task'. 

Doing some investigation I found root cause of the problem in the BPMNParser.checkActivityInputOutputSupported method:

if (!(tagName.contains("Task")
        || tagName.contains("Event")
        || tagName.equals("transaction")
        || tagName.equals("subProcess")
        || tagName.equals("callActivity"))) {
      addError("camunda:inputOutput mapping unsupported for element type '" + tagName + "'.", activityElement);
      return false;
    }

My question is, why camunda:inputOutput mapping unsupported for Task?
It seems so natural and so convenient and will increase usability much more.

Thanks,
Mike

Hi Mike,
It should work as the logic is the exception is thrown if the tag name does not contain ‘Task’. However I note in your exception message, your tagName is a lower case ‘task’. Hence could this be your problem? How did you model your process?

regards

Rob

Hi Rob,

Appreciate your quick response.

I am using Camunda Modeler
image

It produce following xml:

   <bpmn:task id="Task_1amj7k8" name="Update Marketing Preferences">
      <bpmn:extensionElements>
        <camunda:properties>
          <camunda:property />
        </camunda:properties>
        <camunda:inputOutput>
          <camunda:outputParameter name="mktg_preference">email</camunda:outputParameter>
        </camunda:inputOutput>
      </bpmn:extensionElements>
      <bpmn:incoming>SequenceFlow_00246z3</bpmn:incoming>
      <bpmn:outgoing>SequenceFlow_1cx8anx</bpmn:outgoing>
  </bpmn:task>

For others type of tasks it works:

 <bpmn:serviceTask id="Task_02924ne" ...

Do you think it is bug or plain Task shouldn’t support camunda:inputOutput extension?

Thank you,
Mike

What’s the motivation for using input/output parameters on a plain task that the process engine will simply skip?

Cheers,
Thorben

Hi Thorben,

If engine will simply skip why the modeler support all whole bunch of stuff (Async, Listeners, Input/Output, Extensions) for it. Please look:

My motivation regarding input/output parameters is simple, sometimes from logical standpoint I need emphasize a step that actually just ingest a variable into a context.
A plain Task is perfect to do it.

Regards,
Mike

Hi Mike,

Yeah, the modeler should probably not allow defining input/output mappings here. Async and listeners are supported by the way.

Not sure I get this. I understand that when you use BPMN for documentation purposes that you would like to document logical input and outputs of activities. For that, BPMN has data objects which serve the purpose nicely. What I don’t understand is why you would use the technical Camunda properties that have runtime semantics for something that is essentially pointless at runtime.

Cheers,
Thorben

Hi Thorben,

Imagine situation. Process could finished with different results.

.

Later we want to know how many processes were finished with success and with failure.
We can use HistoryService, but we need to put something into the process context.

IMO The plain Task with camunda io extension is best suit for this. Correct me if I am wrong.

PS:

According to the doc DataObject is not supported.

Cheers,
Mike

Hi Mike,

Thanks for explaining your use case. I’d like to propose two alternative solutions:

  1. Instead of the tasks SUCCESS and FAILURE, you could have execution listeners on the sequence flow or on the end events that set a variable to the desired value (e.g. set variable process-result to either success or failure). Then query the history data by that variable. That way, you do not have tasks in the model that do not contribute to the process and are only there for technical reasons (i.e. being able to query the history).
  2. If your prefer a visual representation in the process model, then a popular approach is to use blank intermediate throw events to mark milestones in a process. So the model would look like the one below. This is maybe better than using tasks, as a task in BPMN suggests that something is being done in the process, whereas an event suggests that something has happened (in this case: the milestones have been reached). For these events, you can also use input/output mappings or execution listeners to set the desired variable.

grafik

It is not supported in the sense that data objects have no runtime semantics in the engine. However, the engine also does not complain about them. It will simply ignore them. They won’t help for the use case you explained.

Cheers,
Thorben

1 Like

Thorben,

I will think about the option 2 you mentioned.

Thank you very much for your answers,
Mike