1

I would like to set up a Camel CXF endpont, and have the SOAP response asynchronous to much of my Camel Route. The route will have a lot of processing steps, and I do not want to have the response generated at the very end.

An example endpoint:

<cxf:cxfEndpoint id="someEndpoint"
                     address="/Service"
                     serviceClass="com.SomeImpl" />

An example route:

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.
    }
}

I have tried many options in MyRouteBuilder to "fork" the process (i.e. bean:replyToSOAP):

  1. .multicast().parallelProcessing()
  2. In-memory Asynchronous messaging ("seda" and "vm")
  3. I have NOT tried JMS. It could be overkill for what I want to do.

I can get the route steps to process in parallel, but all steps must be completed before the response is generated.

In addition to the answer Claus gives below, I'd like to add that the placement of wireTap is important. Using:

.wireTap("bean:replyToSOAP")

will not get the desired behavior. What will is:

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");
    }
}
4

1 回答 1

2

有一个 WireTap EIP,它可以旋转消息的副本以独立于当前路由进行处理:http://camel.apache.org/wire-tap

于 2013-07-13T08:55:39.070 回答