camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "James Strachan" <james.strac...@gmail.com>
Subject Re: Apache Camel and calling Spring Business Services
Date Wed, 03 Dec 2008 19:29:19 GMT
2008/12/3 Franklin Antony <franklinantony@gmail.com>:
>
> Dear All,
>  I recently started to use Camel for integration purposes. I am very much
> confused as to where the Spring business services have to be injected into
> Camel. Are they usually injected into RouteBuilder?

These documents are worth a browse...
http://activemq.apache.org/camel/bean-integration.html

in particular this describes how we invoke a bean inside a route
http://activemq.apache.org/camel/bean-binding.html


you can either use it inside a route...

from("jms:someQueue").bean(MyBean.class, "myMethodName");

or using the @Consume annotation
http://activemq.apache.org/camel/pojo-consuming.html

> I have a use case currently where I listen to a directory for new files.
> Then I get the file, rename it and move the file into another directory with
> the new name. During this process I log the old and new file names into the
> database.
>
> This is where problem starts. I have a Spring business service thats does
> the logging for me. I am not sure where and how to inject the business
> service. Also what is the best practice to place the service. Again how is
> it possible to pass the new and old file names to this service ?
>
>
>  from("file://C://test//from").process(new Processor() {
>
>                    public void process(Exchange e) {
>                       //Should the Spring business service for logging to
> DB be called here ??
>                   }
>                }).to("file://C://test//to");
>
> I really don't prefer this . Just feels like the routebuilder is doing more
> that what its supposed to do.
>
> From how much I have used Camel,I am so much happy I am using it now :-D .


from("file://C://test//from").bean(MyClass,
"myMethod").to("file://C://test//to");

You can omit "myMethod" and Camel will probably do the right thing but
it doesn't do any harm to be totally explicit.

-- 
James
-------
http://macstrac.blogspot.com/

Open Source Integration
http://fusesource.com/

Mime
View raw message