Reputation: 535
I want to monitor a directory for zip files and then individually process the files in the zip file using Camel and the Spring DSL. Is something like the following possible?
<camel:route>
<camel:from uri="file:/src/Path/"/>
<camel:split streaming="true">
<zipSplit/>
<camel:to uri="bean:fileProcessor?method=processStream"/>
</camel:split>
</camel:route>
Ok so I found that the following works for a zip file containing one file but the question is how can a zip file containing more than one file be processed?
<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>
Note that the file is not being sent to a bean for processing just unzipped into another directory.
Upvotes: 0
Views: 6339
Reputation: 535
This works. Note the log element will give you the details.
<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&noop=true&idempotent=false"/>
<camel:unmarshal ref="zipFileDataFormat"/>
<camel:split streaming="true">
<camel:simple>${body}</camel:simple>
<camel:to uri="log:org.apache.camel?level=INFO&showAll=true&multiline=true"/>
<camel:to uri="file:///C:/testDst"/>
</camel:split>
</camel:route>
</camel:camelContext>
Upvotes: 5