My requirement is to poll a remote SFTP site on demand and download all of
the files.  I cannot setup a scheduled poller, it will need to be triggered
from an external source.  

The only way I found to do that was to use the consumerTemplate:

Exchange exchange=consumer.receive(uri,2000);

I do this in a loop to pull all of the files.  This is working without issue
on the happy path.  The remote server I am connecting to is pretty flaky, so
I will occasionally see exceptions like this in the logs:

 org.apache.camel.component.file.GenericFileOperationFailedException: Cannot
retrieve file: /out/ttt.gpg
...
Caused by: 4: 
        at com.jcraft.jsch.ChannelSftp._stat(ChannelSftp.java:2200)


My problem is that I cannot recognize that the exception happened!  The
files remain on the remote site as there was an issue getting it, but my
caller has no way of knowing that there was an issue getting the file.

I have tried testing exchange.getException(), but it is always null.  I have
also tried exchange.isFailed() but it's always false.

Is there any way for me to know that the consumerTemplate had issues during
execution?






--
View this message in context: 
http://camel.465427.n5.nabble.com/How-to-handle-exception-within-consumer-tp5767841.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Reply via email to