Oh, and other things: It seems that I don't need the id attribute in the iterate and aggregate mediators. And I don't need any of the attributes of the iterate mediator, either. Except the expression, of course.
2018-01-24 16:23 GMT+01:00 Thomas LEGRAND <[email protected]>: > Hello again, > > I think I start to understand but the mindset to have to understand this > type of process is... twisted. > > If I understood well, the aggregator mediator is like a final one because > it is in its onComplete element you will format your message (or call other > mediators) and send the response. And so, finish the mediation. > > So I modified my sequence to have my iterate mediator which will calls a > sequence which uses the aggregate. So, it like each "iteration" (which can > be parallel) of the iterate mediator will call the "same" sequence and so, > the "same instance" of the aggregate mediator. And, here is the paradox, it > is the "same instance" but not the "same" message. Once you exit the > iterate mediator (with the continueParent), it is finished. You return back > to the original payload used to enter in the iterate mediator. > > I think the documentation should be more explicit about the technical > implication of both of those mediator. For example, when I read the > documentation, I did not understand why we had the iterate in the > inSequence and the aggregate in the outSequence. And why there wasn't any > example of a modification/update of an aggregated content. > > Here is my main sequence with the iterate: > > <iterate continueParent="true" expression="//jsonObject/components" >> id="documentTemplating" preservePayload="true" sequential="true"> >> <target> >> <sequence> >> <log level="custom"> >> <property expression="$body" name="ITERATING..."/> >> </log> >> <property description="numberOfDocument" >> expression="//components/numberOfDocument" name="numberOfDocument" >> scope="default" type="STRING"/> >> <property description="jsonStartDate" >> expression="//components/updatedSince" name="jsonStartDate" >> scope="default" type="STRING"/> >> <property description="sqlDirectoryCriterion" >> expression="//components/directory" name="sqlDirectoryCriterion" >> scope="default" type="STRING"/> >> <property description="sqlSpecificityCriterion" >> expression="//components/specificity" name="sqlSpecificityCriterion" >> scope="default" type="STRING"/> >> <property description="sqlTypologyCriterion" >> 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> >> <log level="full"> >> <property expression="$body" name="ITERATED..."/> >> </log> >> <sequence key="TemplateAggregationSequence"/> >> </sequence> >> </target> >> </iterate> >> > > And my TemplateAggregationSequence with my aggregate: > > <sequence name="TemplateAggregationSequence" trace="disable" xmlns=" >> http://ws.apache.org/ns/synapse"> >> <aggregate description="" id="documentTemplating"> >> <completeCondition> >> <messageCount max="-1" min="-1"/> >> </completeCondition> >> <onComplete expression="//jsonObject/entry"> >> <log level="custom"> >> <property expression="$body" name="AGGREGATING..."/> >> </log> >> </onComplete> >> </aggregate> >> <log leve="full" /> >> <payloadFactory media-type="json"> >> <format>{
 >> entry: [ $1 ]
 >> }</format> >> <args> >> <arg evaluator="xml" expression="//entry"/> >> </args> >> </payloadFactory> >> <respond /> >> </sequence> >> > > Regards, > > Thomas > > PS: I started to understand since I read the explanation of Jean-Michel: > https://stackoverflow.com/questions/42085456/wso2- > change-payload-in-aggregate > > 2018-01-24 11:19 GMT+01:00 Thomas LEGRAND <[email protected]>: > >> 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_-7144552752211485291_m_2802869460910264764_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:jsonStart >>>>> Date}</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.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
