java - How to use sftp in the mule flow after writing a file? -
i have orchestration flow calls subflow write file , next flow (via flow ref) sftp it.
writesubflow
<file:outbound-endpoint path="${outputdir}" outputpattern="${filename}" responsetimeout="10000" doc:name="write file"/> <logger message="file ${filename} written ${outputdir}" level="info" doc:name="end"/>
then call flow (via ref) kicks off sftp process.
<flow name="sftp"> <file:inbound-endpoint path="${outputdir}" connector-ref="file" responsetimeout="10000" doc:name="file"> <file:filename-regex-filter pattern="${filename}" casesensitive="true"/> </file:inbound-endpoint> <sftp:outbound-endpoint exchange-pattern="one-way" connector-ref="sftp" responsetimeout="10000" ref="endpoint" doc:name="sftp" /> </flow>
the problem is
while file being written, flow executes logger after file outbound endpoint , says file written, , after while fileconnector spits out "write file ...". how make logger wait file done writing??
the file inbound endpoint in flow sftp above, executed immiediately , file isnt ready yet. throws exception first saying expecting inputstream or byte[] or string got arraylist(which original payload orchestration flow). after exception printed, file ready , inbound file connector kicks off reads , sftps fine. seems related above question need somehow make rest of flow wait file writing finish.
note: have create sftp flow flow instead of subflow, because needs source. think if dont create flow , have file connector not source, become outbound connector.
any appreciated.
so figured out, somehow both these questions answered in 1 blog post here http://www.sixtree.com.au/articles/2015/advanced-file-handling-in-mule/
the key #1 is
<file:connector name="synchronous-file-connector" doc:name="file"> <dispatcher-threading-profile dothreading="false"/> </file:connector>
for #2 ryan mentions above, using mule requester module.
Comments
Post a Comment