Problem when reading zip files in camel route builder with switchyard
Issue
I am trying to use the Camel ZipSplitter to unzip a zip file and process each file individually. However when trying to do this I get an exception when unzipping the file:
Caught exception of type org.switchyard.HandlerException with message: org.apache.camel.RuntimeCamelException: java.io.EOFException
Caused by exception of type org.apache.camel.RuntimeCamelException, message: java.io.EOFException
Caused by exception of type java.io.EOFException, message: null: org.switchyard.HandlerException: org.apache.camel.RuntimeCamelException: java.io.EOFException
at org.switchyard.component.camel.switchyard.SwitchYardConsumer.handleMessage(SwitchYardConsumer.java:115) [switchyard-component-camel-switchyard-2.0.1.redhat-621084.jar:2.0.1.redhat-621084]
at org.switchyard.handlers.ProviderHandler$1.run(ProviderHandler.java:60) [switchyard-runtime-2.0.1.redhat-621084.jar:2.0.1.redhat-621084]
at org.switchyard.handlers.ProviderHandler$1.run(ProviderHandler.java:58) [switchyard-runtime-2.0.1.redhat-621084.jar:2.0.1.redhat-621084]
at java.security.AccessController.doPrivileged(Native Method) [rt.jar:1.8.0_60]
at javax.security.auth.Subject.doAsPrivileged(Subject.java:549) [rt.jar:1.8.0_60]
...
Caused by: java.io.EOFException
at java.util.zip.ZipInputStream.readFully(ZipInputStream.java:405) [rt.jar:1.8.0_60]
at java.util.zip.ZipInputStream.readLOC(ZipInputStream.java:321) [rt.jar:1.8.0_60]
at java.util.zip.ZipInputStream.getNextEntry(ZipInputStream.java:122) [rt.jar:1.8.0_60]
at org.apache.camel.dataformat.zipfile.ZipIterator.getNextEntry(ZipIterator.java:130) [camel-zipfile-2.15.1.redhat-621084.jar:2.15.1.redhat-621084]
at org.apache.camel.dataformat.zipfile.ZipIterator.getNextElement(ZipIterator.java:98) [camel-zipfile-2.15.1.redhat-621084.jar:2.15.1.redhat-621084]
... 76 more
I am using a file binding in the switchyard project to read the input files:
<sca:service name="Inbound" promote="Component/Inbound">
<sca:interface.java interface="com.example.switchyard.switchyard_zip_test.Inbound"></sca:interface>
<file:binding.file name="file1">
<file:directory>/tmp/input</file:directory>
<file:consume>
<file:move>/tmp/archive</file:move>
<file:moveFailed>/tmp/error</file:moveFailed>
</file:consume>
</file:binding.file>
</sca:service>
and a Camel component to process the file:
<sca:component name="Component">
<camel:implementation.camel>
<camel:java class="com.example.switchyard.switchyard_zip_test.Route"></camel:java>
</camel:implementation.camel>
<sca:reference name="Outbound">
<sca:interface.java interface="com.example.switchyard.switchyard_zip_test.Outbound"></sca:interface>
</sca:reference>
<sca:service name="Inbound">
<sca:interface.java interface="com.example.switchyard.switchyard_zip_test.Inbound"></sca:interface>
</sca:service>
</sca:component>
The com.example.switchyard.switchyard_zip_test.Route
class sets up the Camel definition including Camel ZipSplitter to process the input file:
public void configure() {
from("switchyard://Inbound")
.process(unzipProcessor)
.log("Received message for 'Inbound'")
.split(new ZipSplitter()).streaming()
.log("Trying to send message to 'Outbound'")
.to("switchyard://Outbound")
.log("Message sent to 'Outbound'");
}
Why is the ZipSplitter failing to process the zip file?
Environment
- Red Hat JBoss Fuse
- 6.2.1
Subscriber exclusive content
A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.