Hello Nadeeshaan,
That does not seem to work. I tried with the sequential attribute set in
the aggregate mediator and I can see that the order of the mediators is
respected. But I don't enter in my aggregate. Here is the first line of my
iterator mediator declaration, now:
<iterate continueParent="true" expression="//jsonObject/components"
> sequential="true">
>
I don't know if this is my onComplete expression which is wrong or not
because I noticed that the log with the property named "TEST" and the value
"AFTER ITERATE" shows the original payload. So, how the aggregate can use
the payloads generated in the iterate?
And, in my log with the property named "ITERATED..." with the expression
"$body", I can see both XML and JSON. The JSON seems to be bound to the
Payload and the XML to the property "ITERATED...". The log entry is like
that:
TID: [-1234] [] [2018-01-24 11:11:00,658] INFO
> {org.apache.synapse.mediators.builtin.LogMediator} - To:
> /documents/templates/default/TEST, MessageID:
> urn:uuid:9ac095d4-1d75-4b57-94ed-8c023c7fb0d1,
> Direction: request, ITERATED... = <soapenv:Body xmlns:soapenv="
> http://schemas.xmlsoap.org/soap/envelope/"><jsonObject>MY JSON OBJECT
> CONVERTED TO XML HERE</jsonObject></soapenv:Body>, Payload: MY ORIGINAL
> JSON OBJECT {org.apache.synapse.mediators.builtin.LogMediator}
>
>From that, what should be my expression in my aggregate?
2018-01-24 11:01 GMT+01:00 Nadeeshaan Gunasinghe <[email protected]>:
> 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
> <#m_-78466908292147328_>
> <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:number
>>> OfDocument}</numberOfDocument>
>>> <jsonStartDate>{$ctx:jsonStartDate}</jsonStartDate>
>>> <sqlDirectoryCriterion>{$ctx:s
>>> qlDirectoryCriterion}</sqlDirectoryCriterion>
>>> <sqlSpecificityCriterion>{$ctx
>>> :sqlSpecificityCriterion}</sqlSpecificityCriterion>
>>> <sqlTypologyCriterion>{$ctx:sq
>>> lTypologyCriterion}</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.sy
>>> napse/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