EIP を使用する camel 2.10.6 で書かれたアプリケーションがありますaggregator
。入力として 2 つのファイルを受け取ります。1 つは で終わり-information
、もう1 つは で終わります-report
。両方のファイルを (別々に) 処理する必要があり、処理後に両方を結合(つまりaggregate
) する必要があります。
これを達成するために、私は EIP を使用してい aggregator
ます。spring DSL を使用してルートを定義しました。相関式がありません。つまり、私の式は定数true
です。
<route>
<from uri="activemq:assemblingAll" />
<log message="\n---------->>> @ASSEMBLEALL" />
<aggregate strategyRef="myAggregator" completionSize="2">
<correlationExpression>
<constant>true</constant>
</correlationExpression>
<to uri="activemq:toBeValidated" />
</aggregate>
</route>
一緒に属するファイル、つまり同じプレフィックスを持つファイルを関連付けたいと思います(プレフィックスは前の文字列です(resp。)。これは、ヘッダーにIDを設定することでも可能だと思います。 -information
.report
私の問題は、これを行う方法がわからないことです。今までの私の試みはすべて生成されorg.apache.camel.CamelExchangeException: Invalid correlation key
ました。
ヒントはありますか?
前もって感謝します。
私のルート(簡略化)は次のようになります。
<camelContext xmlns="http://camel.apache.org/schema/spring">
<!-- switchOnFilename" -->
<route>
<from uri="file:/inputdir" />
<choice>
<when>
<simple>${header.CamelFileName} regex '.*-information$'</simple>
<log message="\n---------->>> -information" />
<to uri="activemq:information" />
</when>
<otherwise>
<!-- The default case -->
<log message="\n---------->>> DEFAULT CASE (*-report)" />
<to uri="activemq:report" />
</otherwise>
</choice>
</route>
<route>
<from uri="activemq:information" />
<bean ref="myExtractInformation" />
<to uri="xslt:ExtractInformation.xsl" />
<to uri="activemq:assemblingAll" />
</route>
<route>
<from uri="activemq:report" />
<bean ref="myExtractReports" />
<to uri="xslt:extractReports.xsl" />
<to uri="activemq:assemblingAll" />
</route>
<route>
<from uri="activemq:assemblingAll" />
<log message="\n---------->>> @ASSEMBLEALL" />
<aggregate strategyRef="myAggregator" completionSize="2">
<correlationExpression>
<constant>true</constant>
</correlationExpression>
<to uri="activemq:toBeValidated" />
</aggregate>
</route>
<route>
<from uri="activemq:toBeValidated" />
<doTry>
<to uri="validator:validator.xsd" />
<to uri="activemq:insertUpdateDB" />
<doCatch>
<exception>org.apache.camel.ValidationException</exception>
<log message="INVALID " />
<to uri="mock:invalid" />
</doCatch>
<doFinally>
<log message="Finalizer...." />
<to uri="mock:finally" />
<to uri="mock:invalid" />
</doFinally>
</doTry>
</route>
<route>
<from uri="activemq:insertUpdateDB" />
<setHeader headerName="CamelHttpMethod">
<constant>PUT</constant>
</setHeader>
<setHeader headerName="Content-Type" inheritErrorHandler="true" id="setHeader3">
<constant>application/xml</constant>
</setHeader>
<setHeader headerName="Content-Encoding">
<constant>UTF-8</constant>
</setHeader>
<to uri="http4://localhost:8181/rest/insertUpdateDB" />
</route>