384.5. Aggregate
注記
この集約ストラテジーを適切に機能させるには、完了の先行チェックが必要であることに注意してください。
この例では、入力ディレクトリーで見つかったすべてのテキストファイルを、出力ディレクトリーに格納される 1 つの 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 メッセージヘッダーは、java.io.File.createTempFile を使用して作成され、".zip" 接尾辞が付きます。この動作をオーバーライドする場合は、ルートで 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");