我与类型转换挣扎在我的骆驼航线处理FTP文件。我的路线是这样的(在Spring DSL):骆驼FTP路径和文件类型转换器
<route id="processIncomingFtpFile" errorHandlerRef="parkingCitErrHandler">
<from uri="{{ftp.parkingcit.input.path}}"/>
<bean ref="ftpZipFileHandler"/>
<unmarshal ref="bindyCsvFormat"/>
<bean ref="parkingTicketsHandler"/>
<split>
<simple>${body}</simple>
<marshal ref="jaxbFormatter"/>
<convertBodyTo type="java.io.File"/>
<to uri="{{ftp.parkingcit.output.path}}"/>
</split>
</route>
而且我的处理程序的签名看起来是这样的:
public File handleIncomingFile(File incomingfile)...
然而,我们得到以下类型转换问题:
org.apache.camel.InvalidPayloadException: No body available of type: java.io.File but has value: RemoteFile[test.zip] of type: org.apache.camel.component.file.remote.RemoteFile on: test.zip. Caused by: No type converter available to convert from type: org.apache.camel.component.file.remote.RemoteFile to the required type: java.io.File with value RemoteFile[test.zip]. Exchange[test.zip]. Caused by: [org.apache.camel.NoTypeConversionAvailableException - No type converter available to convert from type: org.apache.camel.component.file.remote.RemoteFile to the required type: java.io.File with value RemoteFile[test.zip]]
我的问题是:我应该能够处理内存中的我的FTP文件,但没有明确告诉骆驼它写入磁盘,与类型转换器做的工作自动地在后台为我后面?或者是什么,我试图做毫无意义的,因为我的处理程序想要一个java.io.File中作为输入参数,即我必须将数据写入磁盘这个工作?
现在看来很明显,你指出了。谢谢。 –