You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Aska Weera <da...@gmail.com> on 2012/09/19 16:19:18 UTC

Invoke Camel route from bean

Hello

I am Camel beginner. This is my first post.  I want service class
(Spring MVC controller/POJO) to call Camel routes.

In some work flows service class expects response and some times it does not.

what is the best way to do that? Camel Proxies or Producer template or
any other way out there?   like
from("myPojo:myMethod").to("direct:start");

thanks

.falik

Re: Invoke Camel route from bean

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

You can take a look at this example
http://camel.apache.org/pojo-messaging-example.html

And check out the links in the bottom of the page as well.


On Wed, Sep 19, 2012 at 4:19 PM, Aska Weera <da...@gmail.com> wrote:
> Hello
>
> I am Camel beginner. This is my first post.  I want service class
> (Spring MVC controller/POJO) to call Camel routes.
>
> In some work flows service class expects response and some times it does not.
>
> what is the best way to do that? Camel Proxies or Producer template or
> any other way out there?   like
> from("myPojo:myMethod").to("direct:start");
>
> thanks
>
> .falik



-- 
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen

Re: Invoke Camel route from bean

Posted by Henryk Konsek <he...@gmail.com>.
Hi,

> In some work flows service class expects response and some times it does not.

If response is requested, consider using asynchronous version of
ProducerTemplate methods returning java.util.Future instances. For
example ProducerTemplate#asyncRequestBody . This approach can
significantly improve performance of typical synchronous MVC
application.

> what is the best way to do that? Camel Proxies or Producer template or
> any other way out there?

It depends :) .

>   like
> from("myPojo:myMethod").to("direct:start");

You can't use Bean component [1] at the beginning of the route. If you
integrate client application with Camel infrastructure you would  like
to start your route with Direct endpoint...

// send message from client (webapp for example)
// to Camel infrastructure.
from("direct:startFromClient").to("seda:camelQueue")

Consider also using Guava Event Bus [2] for that purpose:

// In you MVC controller
@Autowired
EventBus webAppEventBus;
...
webAppEventBus.post(new EventFromMvcController());

// In Camel route
from("guava-eventbus:webAppEventBus").to("seda:camelQueue");

Kind regards.

[1] http://camel.apache.org/bean.html
[2] http://camel.apache.org/guava-eventbus.html

-- 
Henryk Konsek
http://henryk-konsek.blogspot.com