【发布时间】:2013-07-15 10:02:58
【问题描述】:
我想设置一个 Camel CXF 端点,并使 SOAP 响应与我的大部分 Camel Route 异步。路由会有很多处理步骤,我不希望最后生成响应。
一个示例端点:
<cxf:cxfEndpoint id="someEndpoint"
address="/Service"
serviceClass="com.SomeImpl" />
示例路线:
public class MyRouteBuilder extends RouteBuilder {
@Override
public void configure() throws Exception {
from("cxf:bean:someEndpoint")
to("bean:processingStep1")
to("bean:replyToSOAP") // I would like to respond to cxf:cxfEndpoint here!
to("bean:processingStep2")
to("bean:processingStep3")
to("bean:processingStep4");
// The response to cxf:cxfEndpoint actually happens here.
}
}
我在 MyRouteBuilder 中尝试了许多选项来“分叉”该过程(即 bean:replyToSOAP):
- .multicast().parallelProcessing()
- 内存中异步消息传递(“seda”和“vm”)
- 我没有尝试过 JMS。对于我想做的事情来说,这可能有点矫枉过正。
我可以让路由步骤并行处理,但所有步骤必须在生成响应之前完成。
除了克劳斯在下面给出的答案之外,我想补充一点,wireTap 的位置很重要。使用:
.wireTap("bean:replyToSOAP")
不会得到想要的行为。会是什么:
public class MyRouteBuilder extends RouteBuilder {
@Override
public void configure() throws Exception {
from("cxf:bean:someEndpoint")
to("bean:processingStep1")
.wireTap("direct:furtherProcessing")
to("bean:replyToSOAP") // respond to cxf:cxfEndpoint here
from("direct:furtherProcessing") // steps happen independantly of beann:replyToSOAP
to("bean:processingStep2")
to("bean:processingStep3")
to("bean:processingStep4");
}
}
【问题讨论】:
标签: cxf apache-camel