Hi Thomas,

Can you try defining the iterate and aggregate mediator having the* same ID*?
As the example sketch below.

<iterate continueParent="true" expression="//jsonObject/components"
xmlns:ns="http://org.apache.synapse/xsd"; id="YOUR_ID_HERE"></iterate>

<aggregate id="YOUR_ID_HERE"></aggregate>

Cheers,
*Nadeeshaan Gunasinghe*
Senior Software Engineer, WSO2 Inc. http://wso2.com
+94770596754 | [email protected] | Skype: nadeeshaan.gunasinghe <#>
<http://www.facebook.com/nadeeshaan.gunasinghe>
<http://lk.linkedin.com/in/nadeeshaan> <http://twitter.com/Nadeeshaan>
<http://nadeeshaan.blogspot.com/>
Get your own email signature
<https://wisestamp.com/email-install?utm_source=promotion&utm_medium=signature&utm_campaign=get_your_own>

On Wed, Jan 24, 2018 at 3:18 PM, Thomas LEGRAND <
[email protected]> wrote:

> 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
>
>
_______________________________________________
Dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/dev

Reply via email to