0

The route definition is simple based on FTP2 component.

        Endpoint[sftp://server.com:22//path/to/file/?consumer.delay=900000&password=xxxxxx&username=user]

I am trying to read a file from a FTP folder.

   JAXBContext jaxBContext = JAXBContext.newInstance(ObjectFactory.class);
   Unmarshaller unmarshaller = jaxBContext.createUnmarshaller();
   File authBatchFile = exchange.getIn().getBody(File.class);
   AuthorizationFeed batchAuthFeed = (AuthorizationFeed) JAXBIntrospector
            .getValue(unmarshaller.unmarshal(authBatchFile)); 

The exchange has everything it should have

    Body                [Body is file based: RemoteFile[fileName.txt]]

Header also shows the size of the file CamelFileLength=81612. However, I am getting the below exception just after the exchange trace.

  java.lang.IllegalArgumentException: The value for the "java.io.File" parameter cannot be null.
at com.ibm.xml.xlxp2.jaxb.unmarshal.AbstractUnmarshallerImpl.reportNullParameter(AbstractUnmarshallerImpl.java:180)
at com.ibm.xml.xlxp2.jaxb.unmarshal.AbstractUnmarshallerImpl.unmarshal(AbstractUnmarshallerImpl.java:72)
at com.wellpoint.clihub.hie.um.camel.processor.BatchCFFProcessor.process(BatchCFFProcessor.java:47)
4

1 回答 1

3

我通过添加到路由定义找到了解决方案

&localWorkDirectory=/tmp. 

这样它就不会认为它是一个远程文件,而是认为它是一个java.io.File。我认为 Camel 在处理远程文件时应该将其作为默认功能。根据他们的文档,

上面的路线非常高效,因为它避免了将整个文件内容读入内存。它将远程文件直接下载到本地文件流。然后将 java.io.File 句柄用作 Exchange 主体。

于 2014-07-03T19:31:13.190 回答