On Sun, Mar 25, 2012 at 7:25 AM, sushil_vsk5 <[email protected]> wrote:
> Hello:
>
> I have an existing Servlet Container hosting some servlets which receive
> HTTP requests. Now I am planning to develop some Camel routes which will
> reside locally to my web application and shall all start using a "direct:"
> URI.
>
> In this regard, I want to be able to invoke my routes from my existing
> Servlets whenever a request arrives. What is the best way to do this? Should
> I be using a ProducerTemplate? If so, how do I initialize the
> ProducerTemplate to send requests to my "direct:" route endpoint?
>

Yes a producer template is a good way to send a message to a Camel
endpoint from any POJO.

See this FAQ
http://camel.apache.org/why-does-camel-use-too-many-threads-with-producertemplate.html

There ought to be a way with a onInit method on a servlet to get hold
of some context,
where you can lookup / create the producer template.

A very old Camel Axis 1.4 tutorial does that with some spring servlet code
http://camel.apache.org/tutorial-axis-camel.html

> Going forward, I will retire these Servlets and use the camel-http and
> camel-servlets instead.
>
> Also, what if I want to invoke these routes from a simple POJO? Will the
> same approach work?
>

Yeah using producer template from a POJO is a good way to send a
message to a camel route/endpoint.


> Regards,
> Sushil
>
> --
> View this message in context: 
> http://camel.465427.n5.nabble.com/Invoking-Camel-Routes-from-existing-Servlets-POJOS-tp5592834p5592834.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
CamelOne 2012 Conference, May 15-16, 2012: http://camelone.com
FuseSource
Email: [email protected]
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/

Reply via email to