2013-08-22 68 views
0

我想監視一個zip文件的目錄,然後使用Camel和Spring DSL單獨處理zip文件中的文件。是否有如下可能?如何使用Spring DSL處理與駱駝的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文件下面的作品,但問題是如何能包含多個文件壓縮文件進行處理?

<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進行處理,只是解壓縮到另一個目錄。

+0

只是問,你發佈的路線是否有效,或者你是在描述你的期望/要求? – Sikorski

+0

也許可以參考這個.. http://stackoverflow.com/questions/17839379/unzip-a-file-using-apache-camel-unzippedmessageprocessor? – Sikorski

+0

它是更多的要求,它是仿照另一條路線,目前正在爲我工​​作 –

回答

5

This works。注意日誌元素會給你詳細信息。

<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>