具有多个节点的骆驼SFTP幂等终结点仍在生成异常吗?

时间:2019-04-04 07:41:13

标签: apache apache-camel idempotent camel-ftp

我们已经实现了在多节点系统上运行的Camel SFTP端点。为了防止多次提取邮件,我们添加了JdbcMessageIdRepository。通常,这似乎可以正常工作,但是我们似乎无法摆脱一些GenericFileOperationFailedExceptions,在这种情况下,是因为节点希望移动同一文件。我们在设置中是否做错了什么,或者这是带有idempotentRepository实现的SFTP端点的默认行为?如果我们删除“ preMove”属性,则会在JdbcMessageIdRepository上收到违反唯一约束的信息,因此某种程度上该机制似乎并不能确保没有收到重复的消息?

我们的端点的配置:

private String createCamelUrl() {
    return createBaseUrl()
            + "?include=" + includePattern
            + "&preMove=../work"
            + "&move=../history"
            + "&maxDepth=1"
            + "&maxMessagesPerPoll=10"
            + "&readLock=idempotent"
            + "&idempotent=true"
            + "&idempotentKey=${file:name}"
            + "&idempotentRepository=#" + idempotentRepository
            + "&inProgressRepository=#" + idempotentRepository
            + "&privateKeyFile=" + privateKeyFile
            + "&privateKeyFilePassphrase=" + privateKeyFilePassphrase;
}

偶尔会出现Stacktrace:

2019-04-04 06:45:01,655 WARN  | sb/export/outbox | o.a.c.component.file.remote.SftpConsumer | sftp://user@server:port/../../outbox?idempotent=true&idempotentKey=%24%7Bfile%3Aname%7D&idempotentRepository=%23%23jdbcMessageIdRepository&inProgressRepository=%23%23jdbcMessageIdRepository&include=.*%5C.txt&maxDepth=1&maxMessagesPerPoll=10&move=..%2Fhistory&preMove=..%2Fwork&privateKeyFile=%2Fhome%2Fsomething%2F.ssh%2Fid_rsa&privateKeyFilePassphrase=xxxxxx&readLock=idempotent cannot begin processing file: RemoteFile[1554353101529.txt] due to: Cannot rename file from: ../../outbox/1554353101529.txt to: ../../work/1554353101529.txt. Caused by: 
org.apache.camel.component.file.GenericFileOperationFailedException: Cannot rename file from: ../../outbox/1554353101529.txt to: ../../work/1554353101529.txt
        at org.apache.camel.component.file.remote.SftpOperations.renameFile(SftpOperations.java:499)
        at org.apache.camel.component.file.strategy.GenericFileProcessStrategySupport.renameFile(GenericFileProcessStrategySupport.java:128)
        at org.apache.camel.component.file.strategy.GenericFileRenameProcessStrategy.begin(GenericFileRenameProcessStrategy.java:45)
        at org.apache.camel.component.file.GenericFileConsumer.processExchange(GenericFileConsumer.java:362)
        at org.apache.camel.component.file.remote.RemoteFileConsumer.processExchange(RemoteFileConsumer.java:133)
        at org.apache.camel.component.file.GenericFileConsumer.processBatch(GenericFileConsumer.java:223)
        at org.apache.camel.component.file.GenericFileConsumer.poll(GenericFileConsumer.java:187)
        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(Executors.java:511)
        at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308)
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180)
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at java.lang.Thread.run(Thread.java:748)
Caused by: com.jcraft.jsch.SftpException: No such file
        at com.jcraft.jsch.ChannelSftp.throwStatusError(ChannelSftp.java:2873)
        at com.jcraft.jsch.ChannelSftp.rename(ChannelSftp.java:1950)
        at org.apache.camel.component.file.remote.SftpOperations.renameFile(SftpOperations.java:495)
        ... 15 common frames omitted

0 个答案:

没有答案