camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Raul Kripalani <r...@fusesource.com>
Subject Re: How can I update database table by using camel routing?
Date Wed, 16 Nov 2011 13:36:54 GMT
Hi folcadi,

As a side note, our peer Charles Moulliard presented a webinar a few weeks
ago that digs deep into Persistence with Camel, comparing the wide range of
options that Camel offers you to achieve this: camel-jdbc, camel-sql,
camel-jpa, etc.

You can watch the webinar [1] to understand the trade-offs of going one way
or another for your use case. The examples are also downloadable from the
same site.

Additionally, Part II next week will delve into transactions (standalone
and XA), which may be of interest to you.

[1] http://fusesource.com/resources/video-archived-webinars/.

-- Raúl.

On 16 November 2011 06:32, focaldi <ferit.ocaldi@tav.aero> wrote:

> Thanks for your advice Christian, another thanks for Claus :)... I changed
> my
> code like below and it works fine. Now, I wanna ask another question :
> Which
> one is the best solution in your opinion?
>
> public class RouteDatabaseToJms extends RouteBuilder {
>        @Override
>        public void configure() throws Exception {
>
>        DataSource ds = this.getContext().getRegistry().lookup("dataSource",
> DataSource.class);
>         this.getContext().getComponent("sql",
> SqlComponent.class).setDataSource(ds);
>
>
>        //final JdbcTemplate jdbc = new JdbcTemplate(ds);
>
>                final ProducerTemplate template =
> this.getContext().createProducerTemplate();
>
>        from("timer://foo?period=60000").setBody(constant("select * from
> AIRPORT")).to("jdbc:dataSource").
>        process(new Processor(){
>                        @Override
>                        public void process(Exchange exchange) throws
> Exception {
>                                ArrayList<HashMap&lt;String, Object>> data
=
> exchange.getIn().getBody(ArrayList.class);
>                                for (HashMap<String, Object> item : data){
>
>  System.out.println("DATABASE:::item.IATA_CODE
> :"+((String)item.get("IATA_CODE")));
>                                }
>                        }
>        }).to("jms:queue:airport");
>
>        from("jms:queue:airport").process(new Processor(){
>
>                        @Override
>                        public void process(Exchange exchange) throws
> Exception {
>
>                                ArrayList<HashMap&lt;String, Object>> data
=
> exchange.getIn().getBody(ArrayList.class);
>                                for (HashMap<String, Object> item : data){
>
>  template.sendBody("direct:update",(BigDecimal)item.get("ID"));
>                                        //jdbc.update("update airport set
> description_tr='tamam1' where
> id=?",new Object[]{(BigDecimal)item.get("ID")});
>
>  System.out.println("JMS:::item.IATA_CODE
> :"+((String)item.get("IATA_CODE")));
>                                }
>                        }
>
>        });
>
>         from("direct:update").to("sql:update airport set
> description_tr='okkk'
> where id=#");
>
>        }
>
> }
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/How-can-I-update-database-table-by-using-camel-routing-tp4994243p4996795.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message