2016-04-22 72 views
0

輪詢多個文件,我想用下面的駱駝航線,並使用quartz2調度,之後輪詢幾個文件的輪詢從SFTP位置的文件,我「M得到一個GenricFileOperationFailedException caused by java.io.IOException: Pipe closed駱駝SFTP,quartz2組件提供:無法檢索文件:由GenericFileOperationFailedException,當從SFTP

JaxbDataFormat dataFormat = new JaxbDataFormat(); 
dataFormat.setContext(JAXBContext.newInstance(MyBean.class)); 

    from(sftphost + sourcedirpath + 
          "?password=" + password 
         + "&username=" + userName 
         + "&include=" + filePattern 
         + "&localWorkDirectory=" + localWorkingDirectory 
         + "&flatten=true" 
         + "&delete=true" 
         + "&scheduler=quartz2" 
         + "&scheduler.cron=0/45 * * * * ?" 
         + "&stepwise=false" 
         + "&disconnect=true") 
       .onException(Exception.class) 
        .to(sftphost + errdirpath + "?password=" + password + "&username=" + userName+"&disconnect=true") 
        .handled(true) 
        .end() 
       .log(LoggingLevel.INFO, "Processing File : ${file:onlyname}").log(LoggingLevel.INFO, "Before Unmarshalling XML").unmarshal(dataFormat) 
       .log(LoggingLevel.INFO, "after UnMarshalling the XML").beanRef("service", "processData(${body}, ${file:name})") 
       .to(sftphost + processedDirPAth + "?password=" + password + "&username=" + userName+ "&disconnect=true"); 

只有當我使用quartz2計劃我面對這個問題。當我在駱駝路線中使用'& delay = 10000'參數時,上述駱駝路線 完全正常。

錯誤堆棧跟蹤:

2016-04-22 10:33:15,634 | WARN | terface_Worker-1 | SftpConsumer     ] 
    | ?          ? | 264 - 1.0.0.SNAPSHOT | Error processing file RemoteFile[/home/source/file_one.XML 
    ] due to Cannot retrieve file: /home/source/file_one.XML. Caused by: [org.apache.camel.component.file.GenericFileOperat 
    ionFailedException - Cannot retrieve file: /home/source/file_one.XML] 
    org.apache.camel.component.file.GenericFileOperationFailedException: Cannot retrieve file: /home/source/file_one.XML 
      at org.apache.camel.component.file.remote.SftpOperations.retrieveFileToFileInLocalWorkDirectory(SftpOperations.java:735)[264:myBundle:1.0.0.SNAPSHOT] 
      at org.apache.camel.component.file.remote.SftpOperations.retrieveFile(SftpOperations.java:591)[264:myBundle:1.0.0.SNAPSHOT] 
      at org.apache.camel.component.file.GenericFileConsumer.processExchange(GenericFileConsumer.java:396)[264:myBundle:1.0.0.SNAPSHOT] 
      at org.apache.camel.component.file.remote.RemoteFileConsumer.processExchange(RemoteFileConsumer.java:137)[264:myBundle:1.0.0.SNAPSHOT] 
      at org.apache.camel.component.file.GenericFileConsumer.processBatch(GenericFileConsumer.java:211)[264:myBundle:1.0.0.SNAPSHOT] 
      at org.apache.camel.component.file.GenericFileConsumer.poll(GenericFileConsumer.java:175)[264:myBundle:1.0.0.SNAPSHOT] 
      at org.apache.camel.impl.ScheduledPollConsumer.doRun(ScheduledPollConsumer.java:174)[264:myBundle:1.0.0.SNAPSHOT] 
      at org.apache.camel.impl.ScheduledPollConsumer.run(ScheduledPollConsumer.java:101)[264:myBundle:1.0.0.SNAPSHOT] 
      at org.apache.camel.pollconsumer.quartz2.QuartzScheduledPollConsumerJob.execute(QuartzScheduledPollConsumerJob.java:59)[264:myBundle:1.0.0.SNAPSHOT] 
      at org.quartz.core.JobRunShell.run(JobRunShell.java:202)[264:myBundle 
    :1.0.0.SNAPSHOT] 
      at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:573)[264:myBundle:1.0.0.SNAPSHOT] 
    Caused by: 4: 
      at com.jcraft.jsch.ChannelSftp._get(ChannelSftp.java:1160)[264:myBundle:1.0.0.SNAPSHOT] 
      at com.jcraft.jsch.ChannelSftp.get(ChannelSftp.java:1006)[264:myBundle:1.0.0.SNAPSHOT] 
      at com.jcraft.jsch.ChannelSftp.get(ChannelSftp.java:984)[264:myBundle 
    :1.0.0.SNAPSHOT] 
      at org.apache.camel.component.file.remote.SftpOperations.retrieveFileToFileInLocalWorkDirectory(SftpOperations.java:724)[264:myBundle:1.0.0.SNAPSHOT] 
      ... 10 more 
    Caused by: java.io.IOException: Pipe closed 
      at java.io.PipedInputStream.read(PipedInputStream.java:307)[:1.8.0_45] 
      at java.io.PipedInputStream.read(PipedInputStream.java:377)[:1.8.0_45] 
      at com.jcraft.jsch.ChannelSftp.fill(ChannelSftp.java:2882)[264:myBundle:1.0.0.SNAPSHOT] 
      at com.jcraft.jsch.ChannelSftp.header(ChannelSftp.java:2908)[264:myBundle:1.0.0.SNAPSHOT] 
      at com.jcraft.jsch.ChannelSftp._get(ChannelSftp.java:1025)[264:myBundle:1.0.0.SNAPSHOT] 
      ... 13 more 

我還沒有使用這是在駱駝路線被關閉任何其它IO流。

+0

我可以問你使用什麼版本的駱駝?這個錯誤看起來對我來說很熟悉。 –

+0

感謝您的迴應。我使用的駱駝版本是2.15.2。 –

+0

@RaminArabbagheri –

回答

0

這看起來像是目標計算機上的SFTP用戶的權限問題。請查閱https://winscp.net/eng/docs/sftp_codes#code_4瞭解更多詳情。

它可能只是因爲延遲而發生,因爲SSL上下文未立即在Camel FTP2組件中配置/初始化,您需要在開始輪詢之前延遲一小段時間。

+0

感謝您的答覆,我只得到這個問題時,我使用參數「調度= quartz2」,當我使用延遲參數「&延遲= 15000」在mycamel路線我不明白這個問題。 –