我正在使用Camel路径来分割zip文件,并使用以下代码处理它:
return rb -> rb.from("file:{{inbox}}?recursive=true&readLock=markerFile&delay=5000&antInclude=**/*.zip&move=.done")
.routeId("Unzip_File_Route")
.split(new ZipSplitter())
.streaming()
.process(new MyFileProcessor())
.to("file:{{inbox}}?fileName=${header.unzippedPath}")
.end()
;
并且我正在使用一个zip文件来测试它,但是我得到了以下异常:
org.apache.camel.RuntimeCamelException: java.io.IOException: Stream closed
at org.apache.camel.dataformat.zipfile.ZipIterator.getNextElement(ZipIterator.java:125)
at org.apache.camel.dataformat.zipfile.ZipIterator.next(ZipIterator.java:89)
at org.apache.camel.dataformat.zipfile.ZipIterator.next(ZipIterator.java:39)
at org.apache.camel.processor.Splitter$SplitterIterable$1.next(Splitter.java:249)
at org.apache.camel.processor.Splitter$SplitterIterable$1.next(Splitter.java:224)
at org.apache.camel.processor.MulticastProcessor$MulticastReactiveTask.run(MulticastProcessor.java:532)
at org.apache.camel.impl.engine.DefaultReactiveExecutor$Worker.schedule(DefaultReactiveExecutor.java:187)
at org.apache.camel.impl.engine.DefaultReactiveExecutor.scheduleMain(DefaultReactiveExecutor.java:64)
at org.apache.camel.processor.Pipeline.process(Pipeline.java:184)
at org.apache.camel.impl.engine.CamelInternalProcessor.process(CamelInternalProcessor.java:398)
at org.apache.camel.component.file.GenericFileConsumer.processExchange(GenericFileConsumer.java:492)
at org.apache.camel.component.file.GenericFileConsumer.processBatch(GenericFileConsumer.java:245)
at org.apache.camel.component.file.GenericFileConsumer.poll(GenericFileConsumer.java:206)
at org.apache.camel.support.ScheduledPollConsumer.doRun(ScheduledPollConsumer.java:197)
at org.apache.camel.support.ScheduledPollConsumer.run(ScheduledPollConsumer.java:111)
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)
at java.base/java.util.concurrent.FutureTask.runAndReset(FutureTask.java:305)
at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:305)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
at java.base/java.lang.Thread.run(Thread.java:833)
Caused by: java.io.IOException: Stream closed
at java.base/java.io.BufferedInputStream.getInIfOpen(BufferedInputStream.java:157)
at java.base/java.io.BufferedInputStream.fill(BufferedInputStream.java:244)
at java.base/java.io.BufferedInputStream.read1(BufferedInputStream.java:284)
at java.base/java.io.BufferedInputStream.read(BufferedInputStream.java:343)
at java.base/java.io.FilterInputStream.read(FilterInputStream.java:132)
at java.base/java.io.PushbackInputStream.read(PushbackInputStream.java:182)
at java.base/java.util.zip.ZipInputStream.readFully(ZipInputStream.java:418)
at java.base/java.util.zip.ZipInputStream.readLOC(ZipInputStream.java:280)
at java.base/java.util.zip.ZipInputStream.getNextEntry(ZipInputStream.java:124)
at org.apache.camel.dataformat.zipfile.ZipIterator.getNextEntry(ZipIterator.java:139)
at org.apache.camel.dataformat.zipfile.ZipIterator.getNextElement(ZipIterator.java:110)
... 20 common frames omitted
我正在使用Debian来运行这段代码。谢谢
谢谢
1条答案
按热度按时间n6lpvg4x1#
问题出在其他地方。此处
ZipSplitter
中获得的流未关闭,而是由于缺少TypeConverter
而从一开始就为空。添加以下插件将这些转换器添加到jar中,并解决了我的问题: