shawsy
shawsy

Reputation: 467

Java fire and forget cxf web service call to camel application

I have a java web application (quote engine) that makes a web service call to another java web application (multicaster) that utilises Apache camel to multicast a message to multiple endpoints.

We are consuming a apache CXF webservice which is defined in the camel context of the multicaster project. Currently the quote engine project is not using camel.

<cxf:cxfEndpoint id="caster"
        address="http://localhost:${multicaster.port}/caster"
        serviceClass="uk.co.glad.caster.core.casterWS"/>

For additional info here is my multicaster route

        <camel:route id="casterRoute">
            <camel:from ref="caster" />
            <camel:process ref="initProcessor" />
            <camel:multicast parallelProcessing="true" stopOnException="false" streaming="true">
                <camel:to uri="direct:WebService1"/>    
                <camel:to uri="direct:WebService2"/>
            </camel:multicast>
        </camel:route>

I need to the call to the caster cxf endpoint to be fire and forget. I want to send a message to this service and continuing processing in quote engine project without waiting for a reply.

My web service has a void return type as we dont even need a reply.

I think I may be able to solve this using the concurency api and future object but I was wondering if there was a cleaner way to do this. Maybe using camel config, I have read about the "inonly" parameter but I can't see how I can use this in my config.

thanks

Tom

This was solved as Claus mentioned below using wireTap

        <cxf:cxfEndpoint id="caster"
             address="http://localhost:${multicaster.port}/caster"
             serviceClass="uk.co.glad.caster.core.casterWS"/>

        <camel:route id="tap">
            <camel:from ref="caster" />
            <camel:wireTap uri="direct:casterRoute" />
        </camel:route>

    <camel:route id="casterRoute">
        <camel:from uri="direct:casterRoute" />
        <camel:process ref="initProcessor" />
        <camel:multicast parallelProcessing="true" stopOnException="false" streaming="true">
            <camel:to uri="direct:WebService1"/>    
            <camel:to uri="direct:WebService2"/>
        </camel:multicast>
    </camel:route>

Upvotes: 0

Views: 624

Answers (1)

Claus Ibsen
Claus Ibsen

Reputation: 55540

Use the wire tap eip http://camel.apache.org/wire-tap then you can process the tapped message independently, and your CXF web service can terminate asap.

Upvotes: 1

Related Questions