#spring-boot #apache-camel
#весенняя загрузка #apache-camel
Вопрос:
У меня есть выражение sftp, подобное этому:
"sftp://"
hostName
":22"
mainPath
subPath
"?username=" username
"amp;password=" password
fileSecondPrefix
"amp;autoCreate=false" //AYLIK_BELGE_MUTABAKAT_20200706.txt
"amp;strictHostKeyChecking=no"
"amp;preferredAuthentications=publickey,password"
"amp;disconnect=true"
"amp;connectTimeout=50000"
"amp;timeout=50000"
"amp;noop=true"
"amp;maximumReconnectAttempts=2"
"amp;fastExistsCheck=true"
"amp;ignoreFileNotFoundOrPermissionError=false"
"amp;throwExceptionOnConnectFailed=true"
"amp;localWorkDirectory=" "/temp"
"amp;consumer.bridgeErrorHandler=true"
У меня есть маршрут, подобный этому:
nException(Exception.class)
.process(reconciliationExceptionProcessor)
.log(LoggingLevel.INFO, DOCUMENT_RECONCILIATION_ROUTE, "reconciliationExceptionProcessor")
.handled(true)
// .maximumRedeliveries(5).redeliveryDelay(10000L)
.to(SEND_MAIL_FOR_FAILED)
.end();
from(DOCUMENT_RECONCILIATION_ROUTE_START)
.log(LoggingLevel.INFO, DOCUMENT_RECONCILIATION_ROUTE, "Camel route started")
.routeId("reconciliationCamelRoute")
.process(createFTPExpressionProcessor)
// .to(PREPARE_MAIL_FOR_FAILEDS)//todo
.to(GET_FILE_FROM_SFTP)//todo
.log(LoggingLevel.INFO, DOCUMENT_RECONCILIATION_ROUTE, "Camel route ended")
// .end()
;
from(GET_FILE_FROM_SFTP)
.log(LoggingLevel.INFO, DOCUMENT_RECONCILIATION_ROUTE, "Getting the file from SFTP")
.pollEnrich()
.simple("${exchangeProperty.sftpExpression}")
//.timeout(0)
.to(SAVE_RECEIVED_IDS)
.end();
Когда он не может подключиться или не может найти файл, он должен перейти к исключению, а затем должен перейти к маршруту отправки почты, потому что:
nException(Exception.class)
.process(reconciliationExceptionProcessor)
.log(LoggingLevel.INFO, DOCUMENT_RECONCILIATION_ROUTE, "reconciliationExceptionProcessor")
.handled(true)
// .maximumRedeliveries(5).redeliveryDelay(10000L)
.to(SEND_MAIL_FOR_FAILED)
.end();
Но журналы выглядят так:
DocumentReconciliationRoute ReconciliationExceptionProcessor Exception occurred:
Message : Cannot connect to sftp://xxx
[org.apache.camel.component.file.remote.SftpOperations.connect(SftpOperations.java:146), org.apache.camel.component.file.remote.RemoteFileConsumer.connectIfNecessary(RemoteFileConsumer.java:203), org.apache.camel.component.file.remote.RemoteFileConsumer.recoverableConnectIfNecessary(RemoteFileConsumer.java:183), org.apache.camel.component.file.remote.RemoteFileConsumer.prePollCheck(RemoteFileConsumer.java:59), org.apache.camel.component.file.GenericFileConsumer.poll(GenericFileConsumer.java:119), org.apache.camel.impl.ScheduledPollConsumer.doRun(ScheduledPollConsumer.java:175), org.apache.camel.impl.ScheduledPollConsumer.run(ScheduledPollConsumer.java:102), java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511), java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308), java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180), java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294), java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149), java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624), java.lang.Thread.run(Thread.java:748)]
, Cause Message: com.jcraft.jsch.JSchException: java.net.ConnectException: Connection refused (Connection refused)
reconciliationExceptionProcessor appName=maf-integration-offline-services podName=maf-integration-offline-services-842-2bvfx
Exception occurred while trying to handle previously thrown exception on exchangeId: ID-maf-integration-offline-services-842-2bvfx-41923-1598693278891-0-787 using: [Pipeline[[Channel[DelegateSync[com.avivasa.maf.route.offline.reconciliation.processor.ReconciliationExceptionProcessor@445f6f73]], Channel[Log(DocumentReconciliationRoute)[reconciliationExceptionProcessor]], Channel[sendTo(direct://DocumentReconciliationRoute.sendMailForFailed)]]]]. The previous and the new exception will be logged in the following. appName=maf-integration-offline-services podName=maf-integration-offline-services-842-2bvfx
Перед исключением он слишком долго ждал, чтобы вызвать исключение. Тайм-аут = 0 верно? Если я сделаю это, он перейдет к следующему маршруту, и файл станет пустым из exchange, поэтому он выдает исключение, потому что не может найти файл. что хорошо?