user1651118
user1651118

Reputation: 1

Camel 2.18.0 pollEnrich connection exceptions are not caught with OnException block

Im trying to download a file with dynamic filenames using pollEnrich in a loop , when there is a conenction exception at pollEnrich it was not handled in onException block even io cannot us docatch after the pollenrich statment.

i also tried using throwExceptionOnConnectFailed=true in endpoint uri. Not no use.

do this have any workaround?

onException(Exception.class)    
.log( "${exception.stacktrace}")
.end();

from("direct:DownloadFiles")
.loop(exchangeProperty("FileCount"))
.pollEnrich().simple("sftp://testeruser:password@localhost:24?
    move=Processed&antInclude=*${property.soNumber}*.*").timeout(30000)
.to("TARGET SFTP endpoint")
.end();

Upvotes: 0

Views: 1065

Answers (1)

burki
burki

Reputation: 7035

By default Camel ignores connection problems

} catch (Exception e) {
        loggedIn = false;

        // login failed should we thrown exception
        if (getEndpoint().getConfiguration().isThrowExceptionOnConnectFailed()) {
            throw e;
        }
}

Therefore you have to enable the option throwExceptionOnConnectFailed on the SFTP consumer. In your case this would be

.pollEnrich()
     .simple("sftp://testeruser:password@localhost:24?move=Processed&throwExceptionOnConnectFailed=true&antInclude=*${property.soNumber}*.*")
     .timeout(30000)

I know you write in your question that you tried that option without success, but in my test it is this option that decides (according to the Camel code above) if the ConnectException is reaching the error handler or is ignored.

Upvotes: 1

Related Questions