2 Replies Latest reply on Jul 22, 2014 2:33 AM by Joby kj

    Accessing data base from camel route

    Joby kj Newbie

      Hi All,

                We need to validate the camel "from uri " before proceeding to " to uri" . For this write a bean class and configured data source in camel context .  how can we perform sql statements from this bean class and comparing these sql result set with some values from the original " form uri " values ?

       

       

       

      1) Camel route

       

       

      <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" >

        <property name="driverClassName" value="org.postgresql.Driver"/>

        <property name="url" value="jdbc:postgresql://localhost:5432/mydb"/>

        <property name="username" value=""/>

        <property name="password" value=""/>

         <property name="initialSize" value="20" />

         <property name="maxActive" value="30" />

      </bean>

      <bean id="SimpleProcessor" class="com.test.SimpleProcessor"/>

       

         <camelContext xmlns="http://camel.apache.org/schema/spring">

       

             <route id="proxy">

       

       

       

               <from uri="cxf:https://localhost:9091/testProxy?serviceClass=com.test.MyService"/>

       

            

       

               <bean ref="SimpleProcessor" />

       

             

       

                <to uri="cxf:http://localhost:8080/services/myService?serviceClass=com.test.MyService"/>

       

               

       

            

       

               </route>

       

         </camelContext>

       

       

       

      2) SimpleProcessor.java

       

      public class SimpleProcessor implements Processor {

       

        

       

           @Override

       

              public void process(Exchange exchange) {

              int id=100;

         

                // Here need to execute some sql  statement say , select * from customer where id='id'

       

           }

       

       

      Thanks