camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bilgin Ibryam <bibr...@gmail.com>
Subject Re: invoking bean from CAMEL route
Date Sun, 20 Nov 2011 15:09:08 GMT
On Sun, Nov 20, 2011 at 2:16 PM, newbiee <m_essa24@hotmail.com> wrote:
> suppose we have this route:
>
> <bean id="helloBean" class="camelinaction.HelloBean"/>
> <camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
> <route>
>   <from uri="direct:start"/>
>   <bean ref="helloBean" method="hello"/>
> </route>
> </camelContext>
>
> and we have this bean:
>
> public class HelloBean {
> public String hello(String name) {
> return "Hello " + name;
> }
> }
>
> My Questions:
>
> 1. In ="direct:start" , what does start refer to or is this just a name, can
> it be any name?

It is just a name to identify the endpoint, see more here:
http://camel.apache.org/direct.html

> 2. Bean is expecting a parameter and will return the result.

"Camel will use Bean Binding to invoke the bean method, by converting
the Exchange's In body to the String type and storing the output of
the method on the Exchange Out body." - from
http://camel.apache.org/bean.html


> But in the
> route, we are simply calling the hello method. Is this right?

yes

> If there is error, how to correct it?

you have to read also the next chapter from the Camel in Action book :)

> I have taken this from the CAMEL book. Do I need
> to add this line to store the returned result:
>
> <to uri="log:result"/>
>
> again, can we put any name after "log:........" e.g. ="log:result"

It depends what do you want to do next with the message (store or send
it somewhere), in your case simply logging it is fine.

log:result is simply a name, but there are more options also, check it
here: http://camel.apache.org/log.html


HTH
Bilgin Ibryam


>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/invoking-bean-from-CAMEL-route-tp5008230p5008230.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>

Mime
View raw message