Hello everybody,

I have a sequence where I receive JSON with the following format:

{
>    "mixed": true,
>    "dateOrdering": "ASC",
>    "components":    [
>             {
>          "numberOfDocument": 0,
>          "updatedSince": "2017-12-25T00:00:00Z",
>          "directory": "DIRECTORY_2",
>          "specificity": "SPECIFICITY_2",
>          "typology": "TYPOLOGY_2"
>       },
>             {
>          "numberOfDocument": 1,
>          "directory": "DIRECTORY",
>          "specificity": "SPECIFICITY",
>          "typology": "TYPOLOGY"
>       }
>    ]
> }
>

For each entry of the *components* array, I call a custom connector which
returns me JSON. The JSON is set in the body of the message as text and has
the following form:

{"resourceType":"Bundle","entry":[{}, {}, {}]}
>

 My goal is to merge the *entry* array returned by every iteration. But to
understand how that work, for the moment, I implemented an iterate mediator
followed by an aggregate mediator with some logs. Like this:

<iterate continueParent="true" expression="//jsonObject/components"
> xmlns:ns="http://org.apache.synapse/xsd";>
>         <target>
>             <sequence>
>                 <log level="custom">
>                     <property expression="$body" name="ITERATING..."/>
>                 </log>
>                 <property expression="//components/numberOfDocument"
>                     name="numberOfDocument" scope="default" type="STRING"/>
>                 <property expression="//components/updatedSince"
>                     name="jsonStartDate" scope="default" type="STRING"/>
>                 <property expression="//components/directory"
>                     name="sqlDirectoryCriterion" scope="default"
> type="STRING"/>
>                 <property expression="//components/specificity"
>                     name="sqlSpecificityCriterion" scope="default"
> type="STRING"/>
>                 <property expression="//components/typology"
>                     name="sqlTypologyCriterion" scope="default"
> type="STRING"/>
>                 <icl_ged.getDocumentReferencesWithContent>
>
> <numberOfDocument>{$ctx:numberOfDocument}</numberOfDocument>
>                     <jsonStartDate>{$ctx:jsonStartDate}</jsonStartDate>
>
> <sqlDirectoryCriterion>{$ctx:sqlDirectoryCriterion}</sqlDirectoryCriterion>
>
> <sqlSpecificityCriterion>{$ctx:sqlSpecificityCriterion}</sqlSpecificityCriterion>
>
> <sqlTypologyCriterion>{$ctx:sqlTypologyCriterion}</sqlTypologyCriterion>
>                 </icl_ged.getDocumentReferencesWithContent>
>                 <payloadFactory media-type="json">
>                     <format>$1</format>
>                     <args>
>                         <arg evaluator="xml" expression="$body/"
> literal="false"/>
>                     </args>
>                 </payloadFactory>
>                 <log level="full">
>                     <property expression="$body" name="ITERATED..."/>
>                 </log>
>             </sequence>
>         </target>
>     </iterate>
>     <log level="full">
>         <property name="TEST" value="AFTER ITERATE"/>
>     </log>
>     <property name="result" scope="default">
>         <result/>
>     </property>
>     <aggregate>
>         <completeCondition>
>             <messageCount max="-1" min="1"/>
>         </completeCondition>
>         <onComplete enclosingElementProperty="result"
>             expression="$body/jsonObject" xmlns:ns="
> http://org.apache.synapse/xsd";>
>             <log level="custom">
>                 <property expression="$body" name="AGGREGATING..."/>
>             </log>
>         </onComplete>
>     </aggregate>
>

The problem is that it does not seem to enter in the aggregate mediator
and, if I check my logs, I can see that the log with the property named
"TEST" and value "AFTER ITERATE" is evaluated before the log with the
property named "ITERATED" and the expression "$body". I can even see the
"TEST" log before the logs generated by my connector!

Am I missing something?

Regards,

Thomas
_______________________________________________
Dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/dev

Reply via email to