I'm on Enterprise Integrator 6.5. My proxy receives a payload with a file's content and the metadata associated with it. Said metadata may be sent into 1 or more pieces. I need to respond to the frontend with the uploading success and then set the metadata asynchronously.
So I figured out this solution:
- Upload the file to the backend
- Iterate the metadata node from the payload sending messages to a message store
- Respond to the frontend
The file uploads, the metada is set BUT I can't get the code after the Iterate mediator to execute (which is just setting a payload and going to outsequence).
I read on the documentation that "You need to always accompany an Iterate with an Aggregate mediator." but apparently that is meant to be when you use the Send mediator inside the Iterate. My case doesn't seem to fit neither on the ForEach mediator, since documentation says "Use the ForEach mediator only for message transformations. If you need to make back-end calls from each iteration, then use the iterate mediator." Also, the Iterate mediator works perfectly in my case, I find extremely useful attachPath and preservePayload atributes.
Can you please help me solve this?
Weird thing: I set a log inside the iterate mediator and I can't see it in the logs :/
This is my code:
[...]
<log level="full">
<property name="status" value="outside iterate mediator"/>
</log>
<iterate attachPath="//nm:upload" expression="//nm:upload/metadata"
preservePayload="true"
xmlns:nm="http://www.i.com/uploadFileSAPProxy/" xmlns:ns="http://org.apache.synapse/xsd">
<target>
<sequence>
<log level="full">
<property name="status" value="inside iterate mediator"/>
</log>
<payloadFactory media-type="xml">
<format>
<nm:upload
xmlns:b="http://ws.wso2.org/dataservice" xmlns:prx="urn:sap.com:proxy:Q01:/1SAI/TASF285B85AB4507D6C358B:702">
<id_group>$1</id_group>
<section>$2</section>
$3
</nm:upload>
</format>
<args>
<arg evaluator="xml" expression="$ctx:id_group" literal="false"/>
<arg evaluator="xml"
expression="//nm:upload/metadata/section" literal="false"/>
<arg evaluator="xml"
expression="//nm:upload/metadata/values" literal="false"/>
</args>
</payloadFactory>
<property name="messageType" scope="axis2" type="STRING" value="application/json"/>
<property expression="json-eval($.upload)" name="result"
scope="default" type="STRING"/>
<payloadFactory media-type="json">
<format>$1</format>
<args>
<arg evaluator="xml" expression="$ctx:result" literal="false"/>
</args>
</payloadFactory>
<axis2ns29:store
messageStore="uploadFileSAP_v1_putMetadata_ms" xmlns:axis2ns29="http://ws.apache.org/ns/synapse"/>
</sequence>
</target>
</iterate>[...]
Thanks in advance!
I forgot to set continueParent="true"