'Iterate mediator doesn't send response to aggregate mediator
Based on WSO2 documentation, we can use Aggregate mediator to collect responses from Iterate mediator and send back the aggregated data to as response to client, but for some reason, I can't use Aggregate mediator out side the Iterate to get the expected results, the following code stucks in Iterate mediator for ever
<api context="/test" name="test" xmlns="http://ws.apache.org/ns/synapse">
<resource methods="POST GET">
<inSequence>
<iterate description="Students Loop" expression="json-eval($.students)" id="create_students" sequential="true">
<target>
<sequence>
<call blocking="true">
<endpoint key="CreateStudent"/>
</call>
</sequence>
</target>
</iterate>
<aggregate id="create_students">
<completeCondition>
<messageCount max="-1" min="-1"/>
</completeCondition>
<onComplete aggregateElementType="root" expression="json-eval($)"/>
</aggregate>
<respond/>
</inSequence>
<outSequence/>
<faultSequence/>
</resource>
</api>
but the following code is working fine:
<api context="/test" name="test" xmlns="http://ws.apache.org/ns/synapse">
<resource methods="POST GET">
<inSequence>
<iterate description="Students Loop" expression="json-eval($.students)" id="create_students" sequential="true">
<target>
<sequence>
<call blocking="true">
<endpoint key="CreateStudent"/>
</call>
<property name="RESULTS" scope="default">
<students xmlns=""/>
</property>
<aggregate id="create_students">
<completeCondition>
<messageCount max="-1" min="-1"/>
</completeCondition>
<onComplete aggregateElementType="root" enclosingElementProperty="RESULTS" expression="json-eval($)">
<log level="full"/>
</onComplete>
</aggregate>
<respond/>
</sequence>
</target>
</iterate>
</inSequence>
<outSequence/>
<faultSequence/>
</resource>
</api>
Is that means, I have to put Aggregate inside Iterate?
Solution 1:[1]
The first approach is correct, but as I know, the calls should be non-blocking, while we use the aggregate mediator. Otherwise the aggregation does not proceed.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | tmoasz |
