Apache camel 如何使用SpringDSL使用Camel处理zip文件?

Apache camel 如何使用SpringDSL使用Camel处理zip文件?,apache-camel,Apache Camel,我想监视zip文件的目录,然后使用Camel和springdsl分别处理zip文件中的文件。有可能出现以下情况吗 <camel:route> <camel:from uri="file:/src/Path/"/> <camel:split streaming="true"> <zipSplit/> <camel:to uri="bean:fileProcessor?method=processStream"/>

我想监视zip文件的目录,然后使用Camel和springdsl分别处理zip文件中的文件。有可能出现以下情况吗

<camel:route>
  <camel:from uri="file:/src/Path/"/>
  <camel:split streaming="true">
    <zipSplit/>
    <camel:to uri="bean:fileProcessor?method=processStream"/>
  </camel:split>
</camel:route>

好的,我发现下面的方法适用于包含一个文件的zip文件,但问题是如何处理包含多个文件的zip文件

<bean id="zipFileDataFormat" class="org.apache.camel.dataformat.zipfile.ZipFileDataFormat"/>

<camel:camelContext>
    <camel:contextScan/>
    <camel:route>
        <camel:from uri="file:///C:/testSrc/?delay=6000&noop=true&idempotent=false"/>
        <camel:unmarshal ref="zipFileDataFormat"/>
        <camel:to uri="file:///C:/testDst"/>
    </camel:route>
</camel:camelContext>


请注意,文件没有被发送到bean进行处理,只是解压缩到另一个目录中。

这是有效的。注意:log元素将为您提供详细信息

<bean id="zipFileDataFormat" class="org.apache.camel.dataformat.zipfile.ZipFileDataFormat">
    <property name="usingIterator" value="true"/>
</bean>

<camel:camelContext>
    <camel:contextScan/>
    <camel:route id="unzipMultipleFiles">
        <camel:from uri="file:///C:/testSrc/?delay=30000&amp;noop=true&amp;idempotent=false"/>
        <camel:unmarshal ref="zipFileDataFormat"/>
        <camel:split streaming="true">
            <camel:simple>${body}</camel:simple>
            <camel:to uri="log:org.apache.camel?level=INFO&amp;showAll=true&amp;multiline=true"/>
            <camel:to uri="file:///C:/testDst"/>
        </camel:split>
    </camel:route>
</camel:camelContext>

${body}

这很有效。注意:log元素将为您提供详细信息

<bean id="zipFileDataFormat" class="org.apache.camel.dataformat.zipfile.ZipFileDataFormat">
    <property name="usingIterator" value="true"/>
</bean>

<camel:camelContext>
    <camel:contextScan/>
    <camel:route id="unzipMultipleFiles">
        <camel:from uri="file:///C:/testSrc/?delay=30000&amp;noop=true&amp;idempotent=false"/>
        <camel:unmarshal ref="zipFileDataFormat"/>
        <camel:split streaming="true">
            <camel:simple>${body}</camel:simple>
            <camel:to uri="log:org.apache.camel?level=INFO&amp;showAll=true&amp;multiline=true"/>
            <camel:to uri="file:///C:/testDst"/>
        </camel:split>
    </camel:route>
</camel:camelContext>

${body}

只是问一下,您发布的路线是否有效,或者您是否描述了您的期望/要求?请参考此?它更多地围绕着需求,它是基于另一条目前正在为meyes工作的路线建模的。我看到了Java DSL示例,但是其余的应用程序使用Spring DSL,我们需要为我们的支持人员保持一致。您也可以在Spring中编写相同的代码,更改将是最小的。尝试编写一个JavaDSL,首先让它工作起来,然后也许可以将它转换为SpringDSL。{我太懒了,我不想自己做这件事并给你一个答案:)}只是问一下,你发布的路线是否有效,或者你是否描述了你的期望/要求?也许可以参考这个?它更多地围绕着需求,它是基于另一条目前正在为meyes工作的路线建模的。我看到了Java DSL示例,但是其余的应用程序使用Spring DSL,我们需要为我们的支持人员保持一致。您也可以在Spring中编写相同的代码,更改将是最小的。尝试编写一个JavaDSL,首先让它工作起来,然后也许可以将它转换为SpringDSL。{我太懒了,不想自己做这件事,给你一个答案:)}