The ftp consumer produces a WARN message by default when the connection
fails - instead of throwing an exception.
You can use the throwExceptionOnConnectionFailed property to change this
behavior, and then handle the thrown exception from the
PollingConsumerPollStrategy[1] rollback() method.

Note that the default poll strategy will handle the exception. So need to
extend PollingConsumerPollStrategy and implement the rollback() method.
 Have a look at the FtpConsumerThrowExceptionOnLoginFailedTest [2] for an
example.

1.
http://camel.apache.org/maven/current/camel-core/apidocs/org/apache/camel/spi/PollingConsumerPollStrategy.html

2.
http://svn.apache.org/repos/asf/camel/tags/camel-2.8.1/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerThrowExceptionOnLoginFailedTest.java


On Thu, Oct 13, 2011 at 6:48 AM, dportabella <david.portabe...@gmail.com>wrote:

> I have this simple route:
>
> onException(Exception.class)
>  .to("log:com.mycompany.test?level=INFO");
>
> from("sftp://myuser@localhost
> :/files/?password=mypassword&knownHostsFile=/myuser/.ssh/known_hosts&noop=true")
>  .to("log:com.mycompany.test?level=INFO");
>
> If I stop the sftp server, from("sftp:...") throws an
> org.apache.camel.component.file.GenericFileOperationFailedException: Cannot
> connect to sftp://myuser@localhost I would expect that the onException log
> prints something, but it does not. Why??
>
> If I enable the sftp server, the route works and the log after
> from("sftp:...") prints the file content (so, i guess that slf4j is well
> configured).
>
> What can be the problem?
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/Apache-Camel-onException-does-not-get-fired-tp4899276p4899276.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>

Reply via email to