gpt4 book ai didi

file - 使用 Apache Camel 解压缩文件?

转载 作者:行者123 更新时间:2023-12-04 15:23:23 25 4
gpt4 key购买 nike

如何使用 Apache Camel 从 zip 文件中提取文件(一个或多个)?是否可以?

我正在尝试这个

from("file:/home/myinputzip?noop=true&delay=5000&moveFailed=error")
.split(new ZipSplitter())
.streaming().convertBodyTo(String.class)
.to("file:/home/myinputzip")
.end();

当我启动应用程序时,文件是从 zip 中提取出来的,但是 Camel 抛出了一个异常,文件被移动到了错误文件夹:

ERROR: org.apache.camel.processor.DefaultErrorHandler - Failed delivery for (MessageId: ID-ubuntu-35217-1377806407437-0-5 on ExchangeId: ID-ubuntu-35217-1377806407437-0-7). Exhausted after delivery attempt: 1 caught: org.apache.camel.component.file.GenericFileOperationFailedException: Cannot write null body to file: /home/myinputzip/aVIII_crrpfp201304.cap org.apache.camel.component.file.GenericFileOperationFailedException: Cannot write null body to file: /home/myinputzip/aVIII_crrpfp201304.cap at org.apache.camel.component.file.FileOperations.storeFile(FileOperations.java:194) at org.apache.camel.component.file.GenericFileProducer.writeFile(GenericFileProducer.java:257) at org.apache.camel.component.file.GenericFileProducer.processExchange(GenericFileProducer.java:159) at org.apache.camel.component.file.GenericFileProducer.process(GenericFileProducer.java:80) at org.apache.camel.util.AsyncProcessorConverterHelper$ProcessorToAsyncProcessorBridge.process(AsyncProcessorConverterHelper.java:61) at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73) at org.apache.camel.processor.SendProcessor$2.doInAsyncProducer(SendProcessor.java:122) at org.apache.camel.impl.ProducerCache.doInAsyncProducer(ProducerCache.java:298) at org.apache.camel.processor.SendProcessor.process(SendProcessor.java:117)



谁能帮我?

最佳答案

我解决如下

from("file:/home/myinputzip?noop=true&delay=5000&moveFailed=error")
.split(new ZipSplitter())
.streaming().convertBodyTo(String.class)
.choice()
.when(body().isNotNull())
.to("file:/home/myinputzip")
.end()
.end();

关于file - 使用 Apache Camel 解压缩文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18520045/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com