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.

Reply via email to