バッチ モードで実行するように設定されたルートがあり、数千の XML ファイルをポーリングします。それぞれに XML 構造内でタイムスタンプが付けられ、この dateTime 要素を使用して、XML をバッチの以降の処理 (XQuery 変換) に含めるかどうかを決定します。これはバッチ ルートであるため、実行後に自己終了します。
ルートはそれ自体を閉じる必要があるため、すべてのメッセージがフィルターで除外された場合にもルートが閉じるようにする必要があります.choice()
。 XQuery の単一のソース ドキュメントをグループ化して準備する Bean。
ただし、私の現在のアプローチでは、転送の両方のブランチへの 2 番目のルートが必要.choice()
です。これが必要なのは、両方のパスを単純に継続させることはできないように思われるからです。だから私の質問は: どうすればこの 2 番目のルートを取り除くことができますか? 1 つのアプローチは、代わりに Bean にフィルター ヘッダーを設定することですが、関連するオーバーヘッドが心配です。Camel 内の XQuery フィルターは、文字列から XML ドキュメントを構築し、それに対して XQuery を実行する POJO よりもはるかに優れていると思います。
from(sourcePath + "?noop=true" + "&include=.*.xml")
.choice()
.when()
.xquery("[XQuery Filter]")
.setHeader("Filtered", constant(false))
.to("direct:continue")
.otherwise()
.setHeader("Filtered", constant(true))
.to("direct:continue")
.end();
from("direct:continue")
.routeId(forwarderRouteID)
.aggregate(aggregationExpression)
.completionFromBatchConsumer()
.completionTimeout(DEF_COMPLETION_TIMEOUT)
.groupExchanges()
.bean(new FastQueryMerger(), "group")
.to("xquery:" + xqueryPath)
.bean(new FileModifier(interval), "setFileName")
.to(targetPath)
.process(new Processor() {
@Override
public void process(Exchange exchange) throws Exception {
new RouteTerminator(routeID, exchange.getContext()).start();
new RouteTerminator(forwarderRouteID, exchange.getContext()).start();
}
})
.end();