在处理文件和删除文件时从 Camel 配置中获取一些问题。在下面添加了 3 个用例
目的:使用SFTP读取文件并将其复制到本地目录。完成后,将其从 SFTP 位置删除。下面是配置
<from uri="sftp://xxxx@xxxxxx:xxxx/testFolder/ToClient/?password=xxx& delete=true& scheduler=spring& scheduler.cron=0/15+*+*+?+*+MON-SAT& antInclude=*OECExport *.txt"/>
用例 1:当 SFTP 位置只有一个文件时。
属性:<from uri="sftp://xxxx@xxxxxx:xxxx/testFolder/ToClient/?password=xxx& delete=true& scheduler=spring& scheduler.cron=0/15+*+*+?+*+MON-SAT& antInclude=*OECExport *.txt"/>
处理:一切都好
UseCase2 :有多个文件的地方
特性 :<from uri="sftp://xxxx@xxxxxx:xxxx/testFolder/ToClient/?password=xxx& delete=true& scheduler=spring& scheduler.cron=0/15+*+*+?+*+MON-SAT& antInclude=*OECExport *.txt"/>
处理:它没有按预期工作。警告:
2015-11-23 11:21:15,132 | WARN | esFolder/ToClient/ | SftpConsumer | 118 - org.apache.camel.camel-core - 2.13.0 | Error processing file RemoteFile[OECExport20150901_093233_GET_Remote_ToClient.txt] due to Cannot change directory to: riverside. Caused by: [org.apache.camel.component.file.GenericFileOperationFailedException - Cannot change directory to: riverside]
org.apache.camel.component.file.GenericFileOperationFailedException: Cannot change directory to: testFolder
at org.apache.camel.component.file.remote.SftpOperations.doChangeDirectory(SftpOperations.java:542)[279:org.apache.camel.camel-ftp:2.13.0]
at org.apache.camel.component.file.remote.SftpOperations.changeCurrentDirectory(SftpOperations.java:530)[279:org.apache.camel.camel-ftp:2.13.0]
at org.apache.camel.component.file.remote.SftpOperations.retrieveFileToStreamInBody(SftpOperations.java:629)[279:org.apache.camel.camel-ftp:2.13.0]
at org.apache.camel.component.file.remote.SftpOperations.retrieveFile(SftpOperations.java:594)[279:org.apache.camel.camel-ftp:2.13.0]
at org.apache.camel.component.file.GenericFileConsumer.processExchange(GenericFileConsumer.java:362)[118:org.apache.camel.camel-core:2.13.0]
at org.apache.camel.component.file.remote.RemoteFileConsumer.processExchange(RemoteFileConsumer.java:99)[279:org.apache.camel.camel-ftp:2.13.0]
at org.apache.camel.component.file.GenericFileConsumer.processBatch(GenericFileConsumer.java:201)[118:org.apache.camel.camel-core:2.13.0]
at org.apache.camel.component.file.GenericFileConsumer.poll(GenericFileConsumer.java:165)[118:org.apache.camel.camel-core:2.13.0]
at org.apache.camel.impl.ScheduledPollConsumer.doRun(ScheduledPollConsumer.java:187)[118:org.apache.camel.camel-core:2.13.0]
at org.apache.camel.impl.ScheduledPollConsumer.run(ScheduledPollConsumer.java:114)[118:org.apache.camel.camel-core:2.13.0]
at org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:53)[64:org.springframework.context:3.2.4.RELEASE]
at org.springframework.scheduling.concurrent.ReschedulingRunnable.run(ReschedulingRunnable.java:81)[64:org.springframework.context:3.2.4.RELEASE]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)[:1.7.0_55]
at java.util.concurrent.FutureTask.run(FutureTask.java:262)[:1.7.0_55]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:178)[:1.7.0_55]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:292)[:1.7.0_55]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)[:1.7.0_55]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)[:1.7.0_55]
at java.lang.Thread.run(Thread.java:745)[:1.7.0_55]
Caused by: 4:
at com.jcraft.jsch.ChannelSftp.cd(ChannelSftp.java:359)[278:org.apache.servicemix.bundles.jsch:0.1.50.1]
at org.apache.camel.component.file.remote.SftpOperations.doChangeDirectory(SftpOperations.java:540)[279:org.apache.camel.camel-ftp:2.13.0]
... 18 more
Caused by: java.lang.IndexOutOfBoundsException
at java.io.PipedInputStream.read(PipedInputStream.java:372)[:1.7.0_55]
at com.jcraft.jsch.ChannelSftp.fill(ChannelSftp.java:2869)[278:org.apache.servicemix.bundles.jsch:0.1.50.1]
at com.jcraft.jsch.ChannelSftp.fill(ChannelSftp.java:2861)[278:org.apache.servicemix.bundles.jsch:0.1.50.1]
at com.jcraft.jsch.ChannelSftp._realpath(ChannelSftp.java:2319)[278:org.apache.servicemix.bundles.jsch:0.1.50.1]
at com.jcraft.jsch.ChannelSftp.cd(ChannelSftp.java:342)[278:org.apache.servicemix.bundles.jsch:0.1.50.1]
... 19 more
2015-11-23 11:21:30,001 | WARN | testFolder /ToClient/ | eFilePol
UseCase3 :有多个文件的地方
新属性:disconnect=true
特性 :<from uri="sftp://xxxx@xxxxxx:xxxx/testFolder/ToClient/?password=xxx& disconnect=true&delete=true& scheduler=spring& scheduler.cron=0/15+*+*+?+*+MON-SAT& antInclude=*OECExport *.txt"/>
处理:它没有按预期工作。警告:
ons | 279 - org.apache.camel.camel-ftp - 2.13.0 | JSCH -> Disconnecting from sftp.healthedge.com port 2223
2015-11-23 11:25:30,127 | WARN | deSFTPAggregator | GenericFileOnCompletion | 118 - org.apache.camel.camel-core - 2.13.0 | Error during commit. Exchange[OECExport20150901_093233_GET_Remote_ToClient.txt]. Caused by: [org.apache.camel.component.file.GenericFileOperationFailedException - Cannot delete file: testFolder/ToClient/OECExport20150901_093233_GET_Remote_ToClient.txt]
org.apache.camel.component.file.GenericFileOperationFailedException: Cannot delete file: testFolder/ToClient/OECExport20150901_093233_GET_Remote_ToClient.txt
at org.apache.camel.component.file.remote.SftpOperations.deleteFile(SftpOperations.java:387)[279:org.apache.camel.camel-ftp:2.13.0]
at org.apache.camel.component.file.strategy.GenericFileDeleteProcessStrategy.commit(GenericFileDeleteProcessStrategy.java:71)[118:org.apache.camel.camel-core:2.13.0]
at org.apache.camel.component.file.GenericFileOnCompletion.processStrategyCommit(GenericFileOnCompletion.java:124)[118:org.apache.camel.camel-core:2.13.0]
at org.apache.camel.component.file.GenericFileOnCompletion.onCompletion(GenericFileOnCompletion.java:80)[118:org.apache.camel.camel-core:2.13.0]
at org.apache.camel.component.file.GenericFileOnCompletion.onComplete(GenericFileOnCompletion.java:54)[118:org.apache.camel.camel-core:2.13.0]
at org.apache.camel.util.UnitOfWorkHelper.doneSynchronizations(UnitOfWorkHelper.java:100)[118:org.apache.camel.camel-core:2.13.0]
at org.apache.camel.impl.DefaultUnitOfWork.done(DefaultUnitOfWork.java:228)[118:org.apache.camel.camel-core:2.13.0]
at org.apache.camel.util.UnitOfWorkHelper.doneUow(UnitOfWorkHelper.java:61)[118:org.apache.camel.camel-core:2.13.0]
at org.apache.camel.processor.CamelInternalProcessor$UnitOfWorkProcessorAdvice.after(CamelInternalProcessor.java:613)[118:org.apache.camel.camel-core:2.13.0]
at org.apache.camel.processor.CamelInternalProcessor$UnitOfWorkProcessorAdvice.after(CamelInternalProcessor.java:581)[118:org.apache.camel.camel-core:2.13.0]
at org.apache.camel.processor.CamelInternalProcessor$InternalCallback.done(CamelInternalProcessor.java:240)[118:org.apache.camel.camel-core:2.13.0]
at org.apache.camel.processor.Pipeline.process(Pipeline.java:106)[118:org.apache.camel.camel-core:2.13.0]
at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:191)[118:org.apache.camel.camel-core:2.13.0]
at org.apache.camel.component.seda.SedaConsumer.sendToConsumers(SedaConsumer.java:291)[118:org.apache.camel.camel-core:2.13.0]
at org.apache.camel.component.seda.SedaConsumer.doRun(SedaConsumer.java:200)[118:org.apache.camel.camel-core:2.13.0]
at org.apache.camel.component.seda.SedaConsumer.run(SedaConsumer.java:147)[118:org.apache.camel.camel-core:2.13.0]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)[:1.7.0_55]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)[:1.7.0_55]
at java.lang.Thread.run(Thread.java:745)[:1.7.0_55]
Caused by: 4:
at com.jcraft.jsch.ChannelSftp.rm(ChannelSftp.java:1952)[278:org.apache.servicemix.bundles.jsch:0.1.50.1]
at org.apache.camel.component.file.remote.SftpOperations.deleteFile(SftpOperations.java:384)[279:org.apache.camel.camel-ftp:2.13.0]
... 18 more
Caused by: java.io.IOException: inputstream is closed
at com.jcraft.jsch.ChannelSftp.fill(ChannelSftp.java:2871)[278:org.apache.servicemix.bundles.jsch:0.1.50.1]
at com.jcraft.jsch.ChannelSftp.header(ChannelSftp.java:2895)[278:org.apache.servicemix.bundles.jsch:0.1.50.1]
at com.jcraft.jsch.ChannelSftp.rm(ChannelSftp.java:1934)[278:org.apache.servicemix.bundles.jsch:0.1.50.1]
... 19 more
2015-11-23 11:25:30,128 | INFO | edge.com session | SftpOperations | 279 - org.apache.camel.camel-ftp - 2.13.0 | JSCH -> Caught an exception, leaving main loop due to Socket closed
2015-11-23 11:25:30,129 | WARN | edge.com session | eventadmin | 223 - org.apache.felix.eventadmin - 1.3.2 | EventAdmin: Exception: java.lang.InterruptedException
java.lang.InterruptedException
at EDU.oswego.cs.dl.util.concurrent.LinkedQueue.offer(Unknown Source)[223:org.apache.felix.eventadmin:1.3.2]
at EDU.oswego.cs.dl.util.concurrent.PooledExecutor.execute(Unknown Source)[223:org.apache.felix.eventadmin:1.3.2]
at org.apache.felix.eventadmin.impl.tasks.DefaultThreadPool.executeTask(DefaultThreadPool.java:101)[223:org.apache.felix.eventadmin:1.3.2]
at org.apache.felix.eventadmin.impl.tasks.AsyncDeliverTasks.execute(AsyncDeliverTasks.java:105)[223:org.apache.felix.eventadmin:1.3.2]
at org.apache.felix.eventadmin.impl.handler.EventAdminImpl.postEvent(EventAdminImpl.java:100)[223:org.apache.felix.eventadmin:1.3.2]
at org.apache.felix.eventadmin.impl.adapter.LogEventAdapter$1.logged(LogEventAdapter.java:281)[223:org.apache.felix.eventadmin:1.3.2]
at org.ops4j.pax.logging.service.internal.LogReaderServiceImpl.fire(LogReaderServiceImpl.java:134)[8:org.ops4j.pax.logging.pax-logging-service:1.7.2]
at org.ops4j.pax.logging.service.internal.LogReaderServiceImpl.fireEvent(LogReaderServiceImpl.java:126)[8:org.ops4j.pax.logging.pax-logging-service:1.7.2]
at org.ops4j.pax.logging.service.internal.PaxLog
T