[英]Apache Camel spring splitter parallel processing with aggregrator xml is not working as like of Java DSL
What would be equivalent xml for the below java DSL, please suggest以下 java DSL 的等效 xml 是什么,请提出建议
public class OrderRouter1 extends RouteBuilder {
@Override
public void configure() throws Exception {
from("direct:processOrder")
.split(body().method("getItems"), new OrderItemStrategy())
.parallelProcessing()
.to("direct:processItem")
.end();
from("direct:processItem")
.choice()
.when(body().method("getType").isEqualTo("Book"))
.to("bean:itemService?method=processBook").
otherwise()
.to("bean:itemService?method=processPhone");
}
} }
I tried using the below xml configuration, without using aggregator, but when i am enabling parallelprocessing, it is working sequentially.我尝试使用以下 xml 配置,而不使用聚合器,但是当我启用并行处理时,它会按顺序工作。
<camelContext id="orderCtx" xmlns="http://camel.apache.org/schema/spring">
<route>
<from uri="direct:processOrder" />
<split parallelProcessing="true">
<simple>${body}</simple>
<to uri="direct:processItem" />
</split>
</route>
<route>
<from uri="direct:processItem" />
<bean beanType="com.apache.camel.aggregrator.ItemSvc" method="processBook"/>
<bean beanType="com.apache.camel.aggregrator.ItemSvc" method="processPhone"/>
</route>
</camelContext>
i would suggest the following change to the upper route "processOrder"我建议对上层路线“processOrder”进行以下更改
<split parallelProcessing="true">
<simple>${body.getItems}</simple>
<to uri="direct:processItem" />
</split>
if you want to use your AggregationStrategy again, you could add strategyRef="yourBean"
to the splitter如果您想再次使用您的 AggregationStrategy,您可以将
strategyRef="yourBean"
添加到拆分器
Finally i was able to get the equivalent java DSL to XML and its working as expected最后,我能够获得等效的 Java DSL 到 XML 及其按预期工作
<bean id="orderItemStrategy" class="com.apache.camel.aggregrator.OrderItemStrategy" />
<bean id="itemService" class="com.apache.camel.aggregrator.ItemSvc" />
<camelContext id="orderCtx" xmlns="http://camel.apache.org/schema/spring">
<route>
<from uri="direct:processOrder" />
<split parallelProcessing="true" strategyRef="orderItemStrategy">
<simple>${body.getItems}</simple>
<to uri="direct:processItem" />
</split>
</route>
<route>
<from uri="direct:processItem" />
<choice>
<when>
<simple>${body.getType} == 'Book'</simple>
<to uri="bean:itemService?method=processBook" />
</when>
<otherwise>
<to uri="bean:itemService?method=processPhone" />
</otherwise>
</choice>
</route>
</camelContext>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.