camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From uzairkamal <uzair.ka...@iacgrp.com>
Subject Quartz exception with camel
Date Thu, 14 Mar 2013 11:31:33 GMT
Exception in thread "main" java.lang.InstantiationError: org.quartz.JobDetail
	at
org.apache.camel.routepolicy.quartz.ScheduledRoutePolicy.createJobDetail(ScheduledRoutePolicy.java:143)
	at
org.apache.camel.routepolicy.quartz.ScheduledRoutePolicy.scheduleRoute(ScheduledRoutePolicy.java:80)
	at
org.apache.camel.routepolicy.quartz.CronScheduledRoutePolicy.doOnInit(CronScheduledRoutePolicy.java:63)
	at
org.apache.camel.routepolicy.quartz.CronScheduledRoutePolicy.onInit(CronScheduledRoutePolicy.java:35)
	at
org.apache.camel.impl.DefaultRouteContext.commit(DefaultRouteContext.java:207)
	at
org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:883)
	at
org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:172)
	at
org.apache.camel.impl.DefaultCamelContext.startRoute(DefaultCamelContext.java:722)
	at
org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:1789)
	at
org.apache.camel.impl.DefaultCamelContext.doStartCamel(DefaultCamelContext.java:1575)
	at
org.apache.camel.impl.DefaultCamelContext.doStart(DefaultCamelContext.java:1444)
	at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:60)
	at
org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:1412)
	at CamelTests.test(CamelTests.java:79)
	at abc.main(abc.java:17)




Code is as follows


==============================================================================

import com.mysql.jdbc.jdbc2.optional.MysqlDataSource;


import org.apache.camel.*;

import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.jdbc.JdbcEndpoint;
import org.apache.camel.impl.DefaultCamelContext;
import org.apache.camel.impl.JndiRegistry;

import org.apache.camel.routepolicy.quartz.CronScheduledRoutePolicy;

import org.apache.camel.util.jndi.JndiContext;


/*
 * To change this template, choose Tools | Templates and open the template
in
 * the editor.
 */
/**
 *
 * @author Uzair
 */
public class CamelTests {
    
    public void test() throws Exception {
        
        JndiRegistry registry = new JndiRegistry(new JndiContext());
        final CamelContext camelCtxt = new DefaultCamelContext(registry);
        MysqlDataSource datasource = getDataSource();
       final JdbcEndpoint endpoint = getJDBCEndPoint(datasource, camelCtxt);
        
        registry.bind("intuira", getDataSource());
        
        //camelCtxt.addEndpoint("direct:start", endpoint);

    //    camelCtxt.addRoutes(new RouteBuilder() {
      RouteBuilder myRoute = new RouteBuilder(camelCtxt) {

              
            @Override
            public void configure() throws Exception {
                
                
        ProducerTemplate producerTemplate =
camelCtxt.createProducerTemplate();    
    
       try{
                    Endpoint jdbcEndpoint =
camelCtxt.getEndpoint("direct:start");
              
                
              
                MyProcessor routeProcessor = new
MyProcessor(producerTemplate, jdbcEndpoint, camelCtxt);
               
from("direct:start").process(routeProcessor).to("jdbc:intuira");
       
       }catch(Exception ex){
       
       }
               
//from("quartz://myGroup/myTimerName?cron=0+0/1+12-18+?+*+MON-FRI")
                // 
from("timer://kickoff?period=10000").process(routeProcessor).to("jdbc:intuira");

            }
        };
        
          camelCtxt.addRoutes(new RouteBuilder() {

            @Override
            public void configure() throws Exception {
                CronScheduledRoutePolicy policy = new
CronScheduledRoutePolicy();
              
               
                policy.setRouteStartTime("*/3 * * * * ?");
       
from("direct:start").routePolicy(policy).routeId("myRoute").to("mock:results");
            }
          
          
          });
        
        camelCtxt.start();
        
        Thread.sleep(100000);

        camelCtxt.stop();

      
        
    }
    
    private MysqlDataSource getDataSource() {
        MysqlDataSource datasource = new MysqlDataSource();
        datasource.setUser("uzairkamal");
        datasource.setPassword(xxxxxxxxxxxxxxxxxxxx");
        datasource.setDatabaseName("xxxxxxxxxxxxxx");
        datasource.setServerName("xxxxxxxxxxxxxxxx");
        return datasource;
    }
    
    private JdbcEndpoint getJDBCEndPoint(MysqlDataSource datasource,
CamelContext camelCtxt) {
        
        JdbcEndpoint endpoint = new JdbcEndpoint();
        endpoint.setDataSource(datasource);
        endpoint.setCamelContext(camelCtxt);
        return endpoint;
    }
}
==============================================================================





--
View this message in context: http://camel.465427.n5.nabble.com/Quartz-exception-with-camel-tp5729172.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Mime
View raw message