Hi EveryOne

Camel version 2.16.1

We have created a ftp consumer route dynamically as follow: 

from("sftp://fakeuser@fakehost:22"; + 
        "/?password=fakepassword" +
        "&pollStrategy=#pollStrategy" +
        "&recursive=true" +
        "&throwExceptionOnConnectFailed=true" +
        "&delete=true" +
        "&consumer.bridgeErrorHandler=true" +
        "&maximumReconnectAttempts=3")
.onException(Exception.class).handled(true)
        .to("log:errorLog?level=ERROR&showAll=true&multiline=true")
        .setHeader("ANY_MESSAGE", constant("Error occured!"))
        .handled(true)
.end()
.to((new File("c:/temp")).toURI().toString());


The thing is that the configured endpoint cannot handle the situation if the
sftp host is not available. The route cannot reach the onException section
even though consumer.bridgeErrorHandler=true and
throwExceptionOnConnectFailed=true and we have a custom made proxy. 
The custom made proxy is never used because of
throwExceptionOnConnectFailed=true.
It looks like the consumer.bridgeErrorHandler does not do as intended.

The log file instead has produced the following stack trace: 

org.apache.camel.component.file.GenericFileOperationFailedException: Cannot
connect to sftp://fakeuser@fakehost:22
        at
org.apache.camel.component.file.remote.SftpOperations.connect(SftpOperations.java:146)
        at
org.apache.camel.component.file.remote.RemoteFileConsumer.connectIfNecessary(RemoteFileConsumer.java:203)
        at
org.apache.camel.component.file.remote.RemoteFileConsumer.recoverableConnectIfNecessary(RemoteFileConsumer.java:171)
        at
org.apache.camel.component.file.remote.RemoteFileConsumer.prePollCheck(RemoteFileConsumer.java:59)
        at
org.apache.camel.component.file.GenericFileConsumer.poll(GenericFileConsumer.java:106)
        at
org.apache.camel.impl.ScheduledPollConsumer.doRun(ScheduledPollConsumer.java:174)
        at
org.apache.camel.impl.ScheduledPollConsumer.run(ScheduledPollConsumer.java:101)
        at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
        at java.util.concurrent.FutureTask.runAndReset(Unknown Source)
        at
java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(Unknown
Source)
        at
java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(Unknown
Source)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
        at java.lang.Thread.run(Unknown Source)
Caused by: com.jcraft.jsch.JSchException: java.net.UnknownHostException:
fakehost
        at com.jcraft.jsch.Util.createSocket(Util.java:394)
        at com.jcraft.jsch.Session.connect(Session.java:215)
        at
org.apache.camel.component.file.remote.SftpOperations.connect(SftpOperations.java:118)
        ... 13 common frames omitted
Caused by: java.net.UnknownHostException: fakehost
        at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
        at java.net.PlainSocketImpl.connect(Unknown Source)
        at java.net.SocksSocketImpl.connect(Unknown Source)
        at java.net.Socket.connect(Unknown Source)
        at java.net.Socket.connect(Unknown Source)
        at java.net.Socket.<init>(Unknown Source)
        at java.net.Socket.<init>(Unknown Source)
        at com.jcraft.jsch.Util$1.run(Util.java:362)
        ... 1 common frames omitted




--
View this message in context: 
http://camel.465427.n5.nabble.com/SFTP-Consumer-Handle-UnknowHostException-tp5776690.html
Sent from the Camel Development mailing list archive at Nabble.com.

Reply via email to