cancel
Showing results for 
Search instead for 
Did you mean: 

Issue with Multi-Instance variables and extensionElements

wilco
Champ in-the-making
Champ in-the-making
First of all, thanks for this great framework!

In my project I'm switching from Activit 5.11 to 5.14. I'm using a bpmn serviceTask like this:

        <serviceTask id="dicomsort"
                     name="dicomsort"
                     activiti:delegateExpression="${dicomSortIOActivity}">
            <extensionElements>
                <miriam:extension>
                    <miriam:configuration name="dataConsumesTag" value="manualCategorization" />
                    <miriam:configuration name="dataConsumesCategory" value="${category}" />
                    <miriam:configuration name="dataProducesTag" value="dicomsort_${loopCounter}" />
                    <miriam:configuration name="dataProducesCategory" value="${category}" />
                </miriam:extension>
            </extensionElements>          
            <multiInstanceLoopCharacteristics isSequential="true"
                                              activiti:collection="${collection}"
                                              activiti:elementVariable="category" >
            </multiInstanceLoopCharacteristics>
        </serviceTask>


The "miriam:extension" block ist used to configure some custom parameters for serviceTasks. To have a generic approach those parameters are parsed using a BpmnParseHandler implementation during parse time and resolved with an ExecutionListener on the START event during execution. If I'm NOT using a MultiInstanceLoop everything works quite well and also JUEL expressions are resolved as it should … But… when I'm using a MultiInstanceLoop (like the code above) the loop variables (in this case "category" and "loopCounter") cannot be resolved during execution using the ExecutionListener. It complains about:
org.activiti.engine.ActivitiException: Unknown property used in expression: ${category}


Since version 5.11 I was using the multi instance variables in activiti:field variables (without the "miriam:extension" block) , which was working good. But since the change to the BpmnParseHandler interface I needed to refactor my code to use the getExtensionElements() call to retrieve the custom configuration block because the activiti:field fields cannot be read using the getExtensionElements() call.

So is it possible that the Multi Instance variables cannot be retrieved using an ExecutionListener?
5 REPLIES 5

wilco
Champ in-the-making
Champ in-the-making
I did some more investigation:

For me it seems, that the MultiInstanceActivityBehavior is executed AFTER the ExecutionListener. Maybe this is the desired behavior but in my case, the loop variables are not yet set when the executionlistener is fired.

Any idea how to modify this behavior?

Wilco

trademak
Star Contributor
Star Contributor
I don't understand why you switched from using activiti:field variables to the extension elements. To my knowledge we didn't change anything since 5.11 that prevents you from using activiti:field elements. Can you elaborate a bit more on that?

Best regards,

trademak
Star Contributor
Star Contributor
Okay, did you try to use an embedded sub process with the multi instance definition and a service task with the execution listener in the embedded sub process?

Best regards,

wilco
Champ in-the-making
Champ in-the-making
Regarding my refactoring when migrating from 5.11 to 5.14:
In 5.11 I was using Activiti:field members to store custom configuration options. The values of those options were captured via ParseListener and ExecutionListener and stored in a seperate Java object which can be accessed in the serviceTasks. But since 5.14 I have no access to Activiti:field fields using the BpmnParseHandler handler. The BpmnParse.getExtensionElements() doesn't return activiti:field fields. It only returns other custom extension fields (like the one in my first post above). But at the end I like the idea of having a custom section in the extensionElement.

Regarding the sub process:
No, this is not a subprocess. It's just a regular ServiceTask in a multi instance loop.

As I said, the main issue for me seems to be that the ExecutionListener is executed before the Multi Instance behavior is executed. So that's why the loop variables are not available.

In the meantime i tried to implement a custom ActivityBehavior which should do the job of the ExecutionListener. But this did not yet work out very well. Or is there another way?

Wilco

trademak
Star Contributor
Star Contributor
I know it's not a sub process, but you could implement it like I explained. That should work I think.

You should be able to get the field definitions from the ServiceTask instance using the getFieldExtensions method. Did you try that?

Best regards,