65.3. Unmarshal
この例では、MY_QUEUE という ActiveMQ キューから元の形式に Zip ファイルペイロードをアンマーシャリングし、処理のために UnZippedMessageProcessor
に転送します。
from("activemq:queue:MY_QUEUE") .unmarshal().zipFile() .process(new UnZippedMessageProcessor());
from("activemq:queue:MY_QUEUE")
.unmarshal().zipFile()
.process(new UnZippedMessageProcessor());
zip ファイルに複数のエントリーがある場合は、ZipFileDataFormat の usingIterator オプションが true であり、Splitter を使用してさらに作業を行うことができます。
または、以下のように splitter の式として ZipSplitter を使用できます。
from("file:src/test/resources/org/apache/camel/dataformat/zipfile?delay=1000&noop=true") .split(new ZipSplitter()).streaming() .process(new UnZippedMessageProcessor()) .end();
from("file:src/test/resources/org/apache/camel/dataformat/zipfile?delay=1000&noop=true")
.split(new ZipSplitter()).streaming()
.process(new UnZippedMessageProcessor())
.end();
65.3.1. Aggregate リンクのコピーリンクがクリップボードにコピーされました!
この集約ストラテジーが適切に機能するには、Eager 補完チェックが必要です。
この例では、入力ディレクトリーにあるテキストファイルをすべて、出力ディレクトリーに保存されている単一の Zip ファイルに集約します。
from("file:input/directory?antInclude=*/.txt") .aggregate(constant(true), new ZipAggregationStrategy()) .completionFromBatchConsumer().eagerCheckCompletion() .to("file:output/directory");
from("file:input/directory?antInclude=*/.txt")
.aggregate(constant(true), new ZipAggregationStrategy())
.completionFromBatchConsumer().eagerCheckCompletion()
.to("file:output/directory");
送信 CamelFileName
メッセージヘッダーは、接尾辞 ".zip" で java.io.File.createTempFile を使用して作成されます。この動作を上書きする場合は、ルートに CamelFileName
ヘッダーの値を明示的に設定できます。
from("file:input/directory?antInclude=*/.txt") .aggregate(constant(true), new ZipAggregationStrategy()) .completionFromBatchConsumer().eagerCheckCompletion() .setHeader(Exchange.FILE_NAME, constant("reports.zip")) .to("file:output/directory");
from("file:input/directory?antInclude=*/.txt")
.aggregate(constant(true), new ZipAggregationStrategy())
.completionFromBatchConsumer().eagerCheckCompletion()
.setHeader(Exchange.FILE_NAME, constant("reports.zip"))
.to("file:output/directory");