I am converting a csv file, where each csv record is getting converted to json. I am using an iterator mediator to send each json object to an endpoint by modifying it using payload-factory mediator. But I get this VFS error at the end. How can I fix this?
ERROR {VFSTransportSender} - Error while attaching VFS file system properties. null
[2022-07-20 19:30:46,925] ERROR {VFSTransportSender} - Unable to determine out transport information to send message
[2022-07-20 19:30:46,929] ERROR {Axis2Sender} - {proxy:TestProxy} Access-Control-Allow-Credentials:true,Access-Control-Allow-Headers:Authorization, Content-Type, fluent.account,Access-Control-Allow-Methods:POST, PUT, GET, OPTIONS, DELETE,Access-Control-Allow-Origin:*,Access-Control-Expose-Headers:flex.type, flex.version,Access-Control-Max-Age:3600,Cache-Control:no-cache, no-store, max-age=0, must-revalidate,Connection:keep-alive,Content-Type:application/json;charset=UTF-8,Date:Wed, 20 Jul 2022 14:00:47 GMT,Expires:0,Pragma:no-cache,Server:nginx/1.10.3 (Ubuntu),Transfer-Encoding:chunked,X-Content-Type-Options:nosniff,X-Frame-Options:DENY,X-XSS-Protection:1; mode=block, Unexpected error sending message back org.apache.axis2.AxisFault: Unable to determine out transport information to send message
at org.apache.axis2.transport.base.AbstractTransportSender.handleException(AbstractTransportSender.java:234)
at org.apache.synapse.transport.vfs.VFSTransportSender.writeFile(VFSTransportSender.java:331)
at org.apache.synapse.transport.vfs.VFSTransportSender.sendMessage(VFSTransportSender.java:189)
at org.apache.axis2.transport.base.AbstractTransportSender.invoke(AbstractTransportSender.java:119)
at org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:442)
at org.apache.synapse.core.axis2.Axis2Sender.sendBack(Axis2Sender.java:213)
at org.apache.synapse.mediators.builtin.RespondMediator.mediate(RespondMediator.java:46)
at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:109)
at org.apache.synapse.mediators.base.SequenceMediator.mediate(SequenceMediator.java:263)
at org.apache.synapse.core.axis2.Axis2SynapseEnvironment.mediateFromContinuationStateStack(Axis2SynapseEnvironment.java:820)
at org.apache.synapse.core.axis2.Axis2SynapseEnvironment.injectMessage(Axis2SynapseEnvironment.java:322)
at org.apache.synapse.core.axis2.SynapseCallbackReceiver.handleMessage(SynapseCallbackReceiver.java:608)
at org.apache.synapse.core.axis2.SynapseCallbackReceiver.receive(SynapseCallbackReceiver.java:207)
at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:180)
at org.apache.synapse.transport.passthru.ClientWorker.run(ClientWorker.java:298)
at org.apache.axis2.transport.base.threads.NativeWorkerPool$1.run(NativeWorkerPool.java:172)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:834)
Synapse Configs
<?xml version="1.0" encoding="UTF-8"?>
<proxy name="TestProxy" startOnLoad="true" transports="http https vfs" xmlns="http://ws.apache.org/ns/synapse">
<target>
<inSequence>
<smooks config-key="smooks_conf">
<input type="text"/>
<output type="xml"/>
</smooks>
<log level="full"/>
<property name="messageType" scope="axis2" type="STRING" value="application/json"/>
<log>
<property expression="json-eval($)" name="Response"/>
</log>
<call-template target="Template"/>
<log>
<property name="Info" value="Before Iteration"/>
</log>
<iterate continueParent="true" expression="$body//ProductData/Product" id="Iterate-over-products" xmlns:ns="http://org.apache.synapse/xsd">
<target>
<sequence>
<log>
<property name="Info" value="Inside Iteration"/>
</log>
<payloadFactory media-type="json">
<format>
{
"ref": "$1",
"name": "$2",
"summary": "This is a HP",
"attributes": [
{
"name": "imageUrl",
"type": "STRING",
"value": "$3"
},
]
}
}
</format>
<args>
<arg evaluator="json" expression="$.Product.ProductCode" />
<arg evaluator="json" expression="$.Product.ProductName" />
<arg evaluator="json" expression="$.Product.ProductUrl"/>
</args>
</payloadFactory>
<property name="messageType" scope="axis2" type="STRING" value="application/json"/>
<call>
<endpoint>
<http method="post" uri-template""=>
<suspendOnFailure>
<initialDuration>-1</initialDuration>
<progressionFactor>-1</progressionFactor>
<maximumDuration>0</maximumDuration>
</suspendOnFailure>
<markForSuspension>
<retriesBeforeSuspension>0</retriesBeforeSuspension>
</markForSuspension>
</http>
</endpoint>
</call>
<log>
<property expression="json-eval($)" name="product"/>
</log>
</sequence>
</target>
</iterate>
<respond/>
</inSequence>
<outSequence/>
<faultSequence/>
</target>
<parameter name="transport.vfs.Streaming">true</parameter>
<parameter name="transport.PollInterval">1</parameter>
<parameter name="transport.vfs.FileURI">file://C://in</parameter>
<parameter name="transport.vfs.ContentType">text/plain</parameter>
<parameter name="transport.vfs.ActionAfterProcess">MOVE</parameter>
<parameter name="transport.vfs.MoveAfterFailure">file://C:/out</parameter>
<parameter name="transport.vfs.ActionAfterFailure">MOVE</parameter>
<parameter name="transport.vfs.FileNamePattern">.*.csv</parameter>
<parameter name="transport.vfs.MoveAfterProcess">file://C:/history</parameter>
</proxy>
All the logs just before the iterate mediator get printed. The flow stops from the iterate mediator and produce the VFS transport error
Since you are using a custom connector within the template I'm assuming your connector is not properly written which overrides the current message context. Hence after the connector, there is no content to Iterate over. In order to get around this issue save the message to a property after the Smooks
mediator and then restore the message before the Iterate
mediator. For this, You can use the Enrich Mediator
.
To Save the payload
<enrich>
<source type="body"/>
<target type="property" property="jsonPayload"/>
</enrich>
To restore the payload
<enrich description="Restore original payload">
<source clone="false" property="jsonPayload" type="property"/>
<target type="body"/>
</enrich>
Additional notes: When you are using Iterate Mediator
It should be always accompanied by an Aggregate mediator
. You can read more about this here.