You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by André kouamé <ko...@gmail.com> on 2022/11/15 16:13:49 UTC

How can i retrieve file name when SftpException Occured

Hi all,

I want to know if it's possible to get the file name when an error occurred
during a local copy file in SftpOperations.

I have put an OnException but in the processor, i can't get the name of
file because the message has been changed during

GenericFileOperationFailedException.

Best regards,


André Kouamé.

RE: How can i retrieve file name when SftpException Occured

Posted by Daniel Langevin <da...@shq.gouv.qc.ca>.
Hi,

Usually the current message should contain the CamelFileName header when catching exception. If not, before the SFTP transfer you can keep the filename in a property and reuse it afterwards.

<setBody><constant>TEST</constant></setBody>
<setProperty name="fileABC"><simple>{{fileprefixABC}}_${date:now:yyyyMMdd_HHmmss}.txt</simple></setProperty>
<doTry>
   <toD uri="sftp://{{serverABC}}:{{portNumberABC}}{{directoryABC}}?fileName=${exchangeProperty.fileABC}&amp;username={{usernameABC}}&amp;timeout=5000&amp;binary=false&amp;stepwise=true&amp;jschLoggingLevel=ERROR&amp;disconnect=true&amp;throwExceptionOnConnectFailed=true&amp;maximumReconnectAttempts=1&amp;privateKeyFile={{ABC.REPO}}/{{userkeyABC}}&amp;knownHostsFile={{ABC.REPO}}/{{knownHostABC}}&amp;proxy=#proxyout" />
   <doCatch>
       <exception>java.net.ConnectException</exception>
       <exception>java.net.UnknownHostException</exception>
       <exception>com.jcraft.jsch.JSchException</exception>
       <exception>org.apache.camel.component.file.remote.SftpOperations</exception>
       <exception>org.apache.camel.component.file.GenericFileOperationFailedException</exception>
       <log message="CamelFtpReplyCode   = ${header.CamelFtpReplyCode}"/>
       <log message="CamelFtpReplyString = ${header.CamelFtpReplyString}"/>
       <log message="CamelFileName       = ${header.CamelFileName}" />
       <log message="property fileABC    = ${exchangeProperty.fileABC}" />
       <stop/>
   </doCatch>
</doTry>


Hoping that can help.


Daniel Langevin



-----Message d'origine-----
De : André kouamé <ko...@gmail.com> 
Envoyé : 15 novembre 2022 11:14
À : users@camel.apache.org
Objet : How can i retrieve file name when SftpException Occured

Hi all,

I want to know if it's possible to get the file name when an error occurred during a local copy file in SftpOperations.

I have put an OnException but in the processor, i can't get the name of file because the message has been changed during

GenericFileOperationFailedException.

Best regards,


André Kouamé.