Am trying to read a file from a SFTP location . Am using Mule 4.4 Community edition. If there is any error while connecting to SFTP server or file is not present , would like mule to retry 2 times .
So I configured in sftp connector : 'Reconnection strategy' as 'Standard'
However the logs do not show any retry occurring . NOTE - ideally this will be kicked off at a scheduled time ( scheduler ) but for purposes of testing am using a HTTP Listener to invoke the flow
Here is the code :
<sftp:config name="SFTP_Config" doc:name="SFTP Config">
<sftp:connection host="abcd" username="xyz" password="pwd" />
</sftp:config>
<flow name="get:employee">
<logger level="INFO" doc:name="Logger" message="starting search" category="get-employee"/>
<sftp:read doc:name="Read" config-ref="SFTP_Config" path="/a/employees.unl">
<repeatable-in-memory-stream />
<reconnect />
</sftp:read>
<error-handler ></error-handler>
</flow>
Am wondering if I am doing something wrong ? I would want the flow or atleast the file reading to be attempted twice before erroring out.
Presently when the file does not exist in the sftp location it simply throws an error :
Message : Path '/a/employees.unl' doesn't exist
Error type : SFTP:ILLEGAL_PATH
when does the reconnection strategy kick in ? Thanks
Reconnection strategies are for connections, not operations that fail. In your example the connection is working ok. The operation fails because the directory doesn't exists.
For an operations you should put the operation inside an <until-successful>
scope. You can use the maxRetries attribute to specify the number of retries.
Documentation: https://docs.mulesoft.com/mule-runtime/4.4/until-successful-scope