Search code examples
spring-bootapache-camelsftpspring-camelcamel-ftp

Need to Read a file from SFTP endpoint with Proxy enabled in apache camel


I need to read a file from sftp server which is proxy enabled. How to build endpoint for apache camel route with spring boot to consume a file from the sftp folder. Without proxy, i am able to read it from one channel. With proxy enabled for the sftp channel, the spring boot application itself is not starting. I am using apache camel version 4.16.0. Please help me with the syntax how to achieve it.?

sftp://\<sftp_username\>@\<sftp_host\>:\<sftp_port\>\<root_folder\>?delay=5000&delete=true&include=.\*%5C.json&noop=false&password=xxxxxx&proxy=true&proxyHost=\<proxy_host\>&proxyPort=\<proxy_port\>&readLock=rename

Getting the below error:

... 29 common frames omitted Caused by: org.apache.camel.RuntimeCamelException: org.apache.camel.NoTypeConversionAvailableException: No type converter available to convert from type: java.lang.String to the required type: com.jcraft.jsch.Proxy

Trying to read a file but getting an error when starting the application.


Solution

  • The camel documentation doesn't say anything about the proxyHost and proxyPort query parameters. You need to use the parameter proxy, but this is not a boolean, but an implementation of type com.jcraft.jsch.Proxy. For example, if you want to use a Http proxy, you can create a bean like this:

    Proxy myProxy = new ProxyHTTP("localhost", 8080);
    

    You need to then pass this object as a reference to your route, indicated by the #:

    sftp://\<sftp_username\>@\<sftp_host\>:\<sftp_port\>\<root_folder\>?delay=5000&delete=true&include=.\*%5C.json&noop=false&password=xxxxxx&proxy=#myProxy&readLock=rename
    

    https://camel.apache.org/components/4.4.x/sftp-component.html