Multi Process Call Activity with Delegate Variable Mapping

Hello Folks,

I have been working on a BMPN process that at key points uses the Call activity to execute other BMPN processes, the called activities make use of the DelegateVariableMappping solution in order to handle the input and output/result variables from the sub process to the main process.

At one such call activity i found that i required a Multi Process Call Activity to execute a sub process for a defined list of objects.

I expected that the mapping of the results would fail based on the documentation that i found here : multi-instance-io-mapping

Currently i have managed to get the results i wanted via my DelegateVariableMapping class by checking and filling a map variable on the parent process with the individual results of the different types.

The result:

{
 type1_outcome => ObjectValue [value={type1A=SUCCESS, type1B=FAILED}, isDeserialized=true, serializationDataFormat=application/x-java-serialized-object, objectTypeName=java.util.HashMap, serializedValue=160 chars]
 type2_outcome => ObjectValue [value={type2A=FAILED, type2B=SUCCESS}, isDeserialized=true, serializationDataFormat=application/x-java-serialized-object, objectTypeName=java.util.HashMap, serializedValue=152 chars]
...
}

The Delegate code:

public class MergeMultiProcessResults implements DelegateVariableMapping {

@Override
public void mapInputVariables(DelegateExecution superExecution, VariableMap subVariables) {
    // copy all parent variables to the sub process
    subVariables.putAll(superExecution.getVariables());
}

@Override
public void mapOutputVariables(DelegateExecution superExecution, VariableScope subInstance) {
    // extract information and add to the parent process
    String name = subInstance.getVariable("type") + "_outcome";
    Map<String, String> results = (Map<String, String>) superExecution.getVariable(name);
    if (results == null) {
        results = new HashMap<String, String>();
    }

    results.put((String) subInstance.getVariable("typeValue"), (String) subInstance.getVariable("outcome"));
    
    superExecution.setVariable(name, results);
}

Any thoughts about this implementation, as im controlling everything i guess it is ok but would like to gather other users opinions

1 Like

Hi @patrick.corbett,

Your solution looks fine to me.

This restriction only applies to XML-based output mappings, because there you have no possibility to aggregate results.

Cheers,
Thorben

1 Like

Hi @thorben,

Great thanks for the feedback / code review :slight_smile:

Could you please tell me, whether I can use Delegate Variable Mapping Expression in that case ? Without Java

Hello, I’m not sure what you’d like to achieve, id need more information.

My example was using Java, based on the documentation output mapping isnt supported by the engine without writing your own code to handle the mapping.

Read the docs here: multi-instance-io-mapping