无法使骆驼解组zipfile工作?

时间:2019-01-26 20:28:25

标签: apache-camel unmarshalling splitter camel-zipfile

我在骆驼路线上有一个压缩或ZIP文件入站。该zip文件中包含多个CSV文件。我还需要对文件内容进行条件处理,然后再进行进一步处理。看来我可以成功解压缩文件,但无法对它进行解组。似乎多个分离器是一个问题。 ???希望有人能告诉我我在做什么错。如果我从zip文件中取出文件,则可以单独处理所有文件,但不能从zip文件中处理它们。

我尝试过ZipFileDataFormat,也尝试过ZipSplitter,结果相同。尝试过.split(bodyAs(Iterator.class))

        } else if (Boolean.parseBoolean(isCompressedOnly)) { //Only Zipped or Compressed

            ZipFileDataFormat zipFile = new ZipFileDataFormat();
            zipFile.setUsingIterator(true);

            from(fromStr)
            .routeId(routeId)
            .log(LoggingLevel.INFO, "Message received ${file:name} for Only Zipped or Compressed files from host " + host)
            .unmarshal(zipFile)
            .split(body(Iterator.class))
            .streaming()
            .convertBodyTo(String.class)
            .wireTap("file:" + fileArchive)
            .split(body()).streaming()
            .process(new EndpointParametersProcessor(decoderName))
            .to(toStr)
            .end();

1 个答案:

答案 0 :(得分:0)

在对单个csv文件起作用的拆分器操作中添加tokenize(“ \ n”)似乎已解决了我的问题。另外,要将邮件记录重新合并到单个数据包中,请包括一种聚合策略。

        } else if (Boolean.parseBoolean(isCompressedOnly)) { //Only Zipped or Compressed

            ZipFileDataFormat zipFile = new ZipFileDataFormat();
            zipFile.setUsingIterator(true);

            from(fromStr)
            .routeId("Zipped.Only")
            .log(LoggingLevel.INFO, "Message received ${file:name} for Only Zipped or Compressed files from host " + host)
            .unmarshal(zipFile)
            .split(body(Iterator.class))
            .streaming()
            .convertBodyTo(String.class)
            .wireTap("file:" + fileArchive)
            .split(body().tokenize("\n"), new FleetAggregationStrategy()).streaming()
            .process(new EndpointParametersProcessor(decoderName))
            .end()
            .to(toStr);