Camel CXF异步请求和回复

时间:2013-07-12 17:58:23

标签: cxf apache-camel

我想建立一个Camel CXF endpont,并使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):

  1. .multicast()。并行处理()
  2. 内存中异步消息(“seda”和“vm”)
  3. 我没有尝试过JMS。对于我想做的事情来说,这可能有点过头了。
  4. 我可以让路线步骤并行处理,但必须在生成响应之前完成所有步骤。

    除了Claus在下面给出的答案之外,我想补充一点,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");
        }
    }
    

1 个答案:

答案 0 :(得分:2)

WireTap EIP可以独立于当前路线旋转要复制的消息副本:http://camel.apache.org/wire-tap

相关问题