Joining variables from a multiinstance Task

Hi,

I am using Camunda without Java. I have a nodejs app listening on the topics, then that one sends a task to our microservices, and completes the UserTask, then another nodjs worker listens for responses of our microservices and reports back to camunda that the “waitingForMicroservice” task is finished. At that point I store the response from the microservice into a variable in camunda.

Now in my process I have a multi-instance sub process. It runs for an array of image url that I put in the process instance. The microservices that run for these images return categories for the images, which I store in Camunda. But once all instances have run I want to have all these results merged so In the next Task I still have all the information. Now only one instance response value is passed on to the next task.

How should I go about with this? I can put all responses in separate variables like imgCat1 imgCat2 etc. and then merge them manually later on, or I can get the variable imgCat from camunda, then update it in my nodejs worker before I send it back with the value of the current instance, but maybe there is an easier way to have Camunda merge these variables together and create an array of them or something.

I hope someone can answer this.
-thanks-

Hi @mac_doggie,

this topic is not related to the modeler, but the question deserves an answer.

There is not integrated magic to merge data from multi instance activities or subprocesses.

You can either introduce a special task to your subprocess and implement the merge logic (add the local var to the list) in another external task handler or use an end event on the external task and use a script for implementation.

Hope this helps, Ingo

Thanks, I will try.

Hi @mac_doggie,

here is a good post that explains how you can handle and implement the logic you want to achieve.

Hope this helps.

Regards
Michael