0
votes

In my Camel application there are 2 CXF endpoints that are handled by the same processing route, and AFAIK each endpoint may produce Exchanges in parallel depending on incoming HTTP requests.
Both endpoints forward the request through the same route using direct: component, which is sometimes described as the Camel equivalent of calling a method.

The direct: component provides direct, synchronous invocation of any consumers when a producer sends a message exchange.

My questions:

  • Does direct: component run different requests in parallel? (each request has its own Exchange and is executed by a different java Thread)
  • If not, how do I handle CXF requests in parallel?

This is my situation:

<route id="CxfRoute1">
    <from uri="cxf:bean:endpoint1" />
    <to uri="direct:handle" />
</route>

<route id="CxfRoute2">
    <from uri="cxf:bean:endpoint2" />
    <to uri="direct:handle" />
</route>

<route id="HandleStuffRoute" />
    <from uri="direct:handle" />
    <to uri="bean:stuffHandler" />
</route>
3
how can 2 requests arrive at your route at exactly the same time? There will be some sort of queue, even at the TCP level, I would think. Sounds like it will always execute one CXF endpoint at a time. - E LaRoche
They may be sequential at TCP level and parallel at execution/thread level. I don't want to block until one request has finished processing. - Alessandro Da Rugna

3 Answers

1
votes

In your case yes it should run the different requests in parallel.

You can probably create a Camel unit test that tests this. In your route test class you can create a new route that is timer based and then create some dummy body and call your route endpoints like this:

 .parallelProcessing().to("cxf1", "cxf2", "cxf3")

and then observe the results.

I guess another way is to use JMeter and create a test against your cxf endpoints and observe.

1
votes

It works like a direct method call, eg Foo foo = ... ; foo.callSomeMethod() which uses the current thread to call. So you get parallel from the consumer in this example CXF, so if 2+ clients call CXF at the same time, each calls runs in its own thread, and each of them call direct as a direct method invocation and all that can run in parallel.

0
votes

For handling parallel requests in the same way as using direct you can use "seda" instead. Details at http://camel.apache.org/seda