It's extremely important to learn the EIPs available to you in Camel and
leverage them to the greatest extent possible.  They'll do a lot of the
heavy lifting.  You can use a CBR to send data to various routes or beans
based on some value in the data header or body, for example.

I handle SOAP requests all the time without using Processors.  As an
example of how this is easily accomplished look at this snippet of
blueprint.  It could be done in others as well.

<recipientList>
<simple>direct-vm:${header.operationName}</simple>
</recipientList>

The operation name there is set on the method of the SOAP interface or in
the WSDL (though I usually go code first.)

If you set up routes that are based on the operation name listening on that
then they will receive the message.  So here's a definition of an API and
I've decorated it for use in both the SOAP and REST endpoints.  (The REST
endpoints/uris in @Path are named incorrectly here as they should be noun
based but it gets the idea across.)

@WebMethod(operationName = "getFoo", action = "")
@GET
@Path("/resource/bar/{token}")
@Produces({MediaType.APPLICATION_JSON,MediaType.APPLICATION_XML})
@Consumes({MediaType.APPLICATION_JSON,MediaType.APPLICATION_JSON})
public String getFoo(@WebParam Foo foo);
@WebMethod(operationName = "addFoo", action = "")
@PUT
@Path("/resource/foo/{token}")
@Produces({MediaType.APPLICATION_JSON,MediaType.APPLICATION_XML})
@Consumes({MediaType.APPLICATION_JSON,MediaType.APPLICATION_JSON})
public void addFoo(@WebParam Foo foo);

So we have this in our SOAP and REST related camel contexts/routes.
<recipientList>
<simple>direct-vm:${header.operationName}</simple>
</recipientList>



<camelContext id="Foo-SOAP-context" xmlns="
http://camel.apache.org/schema/blueprint";>

<route id="Foo-SOAP">
<from uri="cxf:bean:fooSOAPEndpoint" />

<transform>
<simple>${body[0]}</simple>
</transform>

<recipientList>
<simple>direct-vm:${header.operationName}</simple>
</recipientList>
</route>
</camelContext>

In the same or different bundle you can then add:

<route id="fooAddRoute">
       <from uri="direct-vm:addFoo">
       <bean ref="fooAddHandler"/>
        <to ...whoever is next or if nothing, then return something from
the handler or if the SOAP/REST endpoint is void return nothing.

</route>

Now whether the request is coming in through SOAP or REST it is will invoke
the addFoo route, unmarshal the object into a Foo object, and send it to
the route.

No need to use Processors, ProducerTemplates or anything else.  Just let
Camel do the work for you and learn the EIPs!

On Sun, Sep 11, 2016 at 12:19 AM, niteshjain <niteshjain...@gmail.com>
wrote:

> I'm using Processor interface, to handle the incoming SOAP request from the
> Exchange and apply some business logic on it, Based on the business logic I
> wanted to invoke different camel routes (defined in camel context xml),
> hence ProducerTemplate to invoke different camel routes.
>
> Regards,
> Nithesh
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.
> com/ProducerTemplate-creates-too-much-threads-tp5751299p5787445.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>

Reply via email to