【发布时间】:2015-07-19 13:21:12
【问题描述】:
我是 Camel 的新手,我正在尝试执行以下操作。
我想处理两次相同的消息。我必须先转换两条消息并处理一条消息,然后只有在成功执行第一条消息时才处理第二条消息(我有一个条件)。
我首先尝试使用多播。然后我转换每条路由中的消息。第一个(操作_DC)仅在成功时才向第二个(操作_AC)发送成功消息。第二个操作包含一个聚合,该聚合等待两条消息都超时。我只想处理来自多播的消息并丢弃另一个。
<route id="t_operation_ME">
<from uri="direct:operation_ME" id="t.direct.aggregatedService"></from>
<setHeader headerName="id">
<simple>exchangeId</simple>
</setHeader>
<multicast parallelProcessing="true" strategyRef="defaultAggregationStrategy" stopOnException="true" onPrepareRef="cleanHeader" parallelAggregate="false" completionPredicate="">
<to uri="direct:operation_DC"></to>
<to uri="direct:operation_AC"></to>
</multicast>
</route>
<route id="direct:operation_DC">
<from uri="direct:operation_DC" />
<log message="ENTER DC"></log>
<to uri="xslt:{{depasse:core.transformation.xml.path}}client/t/Operation_toDC_request.xsl" id="t.dc.transform.productos" />
<to uri="activemq:QCIn" id="t.dc.qcin.queue.send"></to>
<log message="EXIT DC ${body}"></log>
<choice>
<when>
<xpath>//Data/Status[. = 'OK']</xpath>
<log message="SEND TO AC"></log>
<to uri="direct:operation_AC"></to>
</when>
</choice>
</route>
<route id="direct:operation_AC">
<from uri="direct:operation_AC" />
<log message="ENTER AC"></log>
<aggregate completionTimeout="20000" completionSize="2" discardOnCompletionTimeout="true" strategyRef="tAggregationStrategy">
<correlationExpression>
<simple>header.id</simple>
</correlationExpression>
<log message="ENTER AGG AC ${body}"></log>
<to uri="xslt:{{depasse:core.transformation.xml.path}}client/t/Operation_toAC_request.xsl" id="t.ac.transform.productos" />
<to uri="activemq:QCIn" id="t.ac.qcin.queue.send"></to>
<log message="EXIT AC ${body}"></log>
</aggregate>
<log message="END AC\n${body}"></log>
</route>
问题是,当我记录“EXIT AC”和“END AC”时,消息是不同的。这意味着当我在服务器中正确观看该过程时,AC 客户端收到了不正确的消息。
【问题讨论】:
-
路由 id 是 operationCDI_AC 而不是 operation_AC。对吗?
-
你说得对。但是我更改了所有名称以便在 StackOverflow 中发布问题。我编辑了这个问题,你应该看到它就像“operation_AC”一样简单。
标签: apache-camel