• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java QuartzComponent类的典型用法和代码示例

java 3次浏览

本文整理汇总了Java中org.apache.camel.component.quartz2.QuartzComponent的典型用法代码示例。如果您正苦于以下问题:Java QuartzComponent类的具体用法?Java QuartzComponent怎么用?Java QuartzComponent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。

QuartzComponent类属于org.apache.camel.component.quartz2包,在下文中一共展示了QuartzComponent类的27个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: testScheduledStopRoutePolicy

点赞 3

import org.apache.camel.component.quartz2.QuartzComponent; //导入依赖的package包/类
@Test
public void testScheduledStopRoutePolicy() throws Exception {
    context.getComponent("quartz2", QuartzComponent.class).setPropertiesFile("org/apache/camel/routepolicy/quartz2/myquartz.properties");
    context.addRoutes(new RouteBuilder() {
        public void configure() {
            CronScheduledRoutePolicy policy = new CronScheduledRoutePolicy();
            policy.setRouteStopTime("*/3 * * * * ?");
            policy.setRouteStopGracePeriod(0);
            policy.setTimeUnit(TimeUnit.MILLISECONDS);
            
            from("direct:start")
                .routeId("test")
                .routePolicy(policy)
                .to("mock:unreachable");
        }
    });
    context.start();
    
    Thread.sleep(5000);
    assertTrue(context.getRouteStatus("test") == ServiceStatus.Stopped);
}
 

开发者ID:HydAu,
项目名称:Camel,
代码行数:22,
代码来源:CronScheduledRoutePolicyTest.java

示例2: testScheduledStopRoutePolicyWithExtraPolicy

点赞 3

import org.apache.camel.component.quartz2.QuartzComponent; //导入依赖的package包/类
@Test
public void testScheduledStopRoutePolicyWithExtraPolicy() throws Exception {
    final MyRoutePolicy myPolicy = new MyRoutePolicy();

    context.getComponent("quartz2", QuartzComponent.class).setPropertiesFile("org/apache/camel/routepolicy/quartz2/myquartz.properties");
    context.addRoutes(new RouteBuilder() {
        public void configure() {
            CronScheduledRoutePolicy policy = new CronScheduledRoutePolicy();
            policy.setRouteStopTime("*/3 * * * * ?");
            policy.setRouteStopGracePeriod(0);
            policy.setTimeUnit(TimeUnit.MILLISECONDS);

            from("direct:start")
                .routeId("test")
                .routePolicy(policy, myPolicy)
                .to("mock:unreachable");
        }
    });
    context.start();
    
    Thread.sleep(5000);

    assertTrue(context.getRouteStatus("test") == ServiceStatus.Stopped);
    assertTrue("Should have called onStart", myPolicy.isStart());
    assertTrue("Should have called onStop", myPolicy.isStop());
}
 

开发者ID:HydAu,
项目名称:Camel,
代码行数:27,
代码来源:CronScheduledRoutePolicyTest.java

示例3: testScheduledSuspendRoutePolicy

点赞 3

import org.apache.camel.component.quartz2.QuartzComponent; //导入依赖的package包/类
@Test
public void testScheduledSuspendRoutePolicy() throws Exception {
    context.getComponent("quartz2", QuartzComponent.class).setPropertiesFile("org/apache/camel/routepolicy/quartz2/myquartz.properties");
    context.addRoutes(new RouteBuilder() {
        public void configure() {
            CronScheduledRoutePolicy policy = new CronScheduledRoutePolicy();
            policy.setRouteSuspendTime("*/3 * * * * ?");
            
            from("direct:start")
                .routeId("test")
                .routePolicy(policy)
                .to("mock:unreachable");
        } 
    });
    context.start();
    
    Thread.sleep(5000);

    // when suspending its only the consumer that suspends
    // there is a ticket to improve this
    Consumer consumer = context.getRoute("test").getConsumer();
    SuspendableService ss = (SuspendableService) consumer;
    assertTrue("Consumer should be suspended", ss.isSuspended());
}
 

开发者ID:HydAu,
项目名称:Camel,
代码行数:25,
代码来源:CronScheduledRoutePolicyTest.java

示例4: testMultiplePoliciesOnRoute

点赞 3

import org.apache.camel.component.quartz2.QuartzComponent; //导入依赖的package包/类
@Test
public void testMultiplePoliciesOnRoute() throws Exception {
    MockEndpoint success = context.getEndpoint("mock:success", MockEndpoint.class);        
    success.expectedMinimumMessageCount(size - 10);
    
    context.getComponent("quartz2", QuartzComponent.class).setPropertiesFile("org/apache/camel/routepolicy/quartz2/myquartz.properties");
    context.addRoutes(new RouteBuilder() {
        public void configure() {   
            from(url)
                .routeId("test")
                .routePolicyRef("startPolicy, throttlePolicy")
                .to("log:foo?groupSize=10")
                .to("mock:success");
        }
    });
    context.start();

    assertTrue(context.getRouteStatus("test") == ServiceStatus.Started);
    for (int i = 0; i < size; i++) {
        template.sendBody(url, "Message " + i);
        Thread.sleep(3);
    }

    context.getComponent("quartz2", QuartzComponent.class).stop();
    success.assertIsSatisfied();
}
 

开发者ID:HydAu,
项目名称:Camel,
代码行数:27,
代码来源:MultiplePoliciesOnRouteTest.java

示例5: configure

点赞 3

import org.apache.camel.component.quartz2.QuartzComponent; //导入依赖的package包/类
@Override
public void configure() throws Exception {

    final CountDownLatch startLatch = new CountDownLatch(1);

    // verify that a component can be added manually
    getContext().addComponent("quartz2", new QuartzComponent() {
        @Override
        public void onCamelContextStarted(CamelContext context, boolean alreadyStarted) throws Exception {
            super.onCamelContextStarted(context, alreadyStarted);
            startLatch.countDown();
        }
    });

    from("quartz2://mytimer?trigger.repeatCount=3&trigger.repeatInterval=100")
    .process(new Processor() {
        @Override
        public void process(Exchange exchange) throws Exception {
            if (startLatch.getCount() > 0)
                throw new IllegalStateException("onCamelContextStarted not called");
        }
    })
    .to(MOCK_RESULT_URI);
}
 

开发者ID:wildfly-extras,
项目名称:wildfly-camel,
代码行数:25,
代码来源:RouteBuilderF.java

示例6: components

点赞 2

import org.apache.camel.component.quartz2.QuartzComponent; //导入依赖的package包/类
@Override
public ImmutableMap<String, Component> components() {
	QuartzComponent quartzComponent = new QuartzComponent();
	quartzComponent.setEnableJmx(false); //Standalone scheduler, no need to register it in mbean
	HttpComponent httpComponent = new HttpComponent();
	return ImmutableMap.of("http", httpComponent, "https", httpComponent, "quartz", quartzComponent);
}
 

开发者ID:LuatixHQ,
项目名称:openex-worker,
代码行数:8,
代码来源:SchedulerExecutor.java

示例7: doOnInit

点赞 2

import org.apache.camel.component.quartz2.QuartzComponent; //导入依赖的package包/类
protected void doOnInit(Route route) throws Exception {
    QuartzComponent quartz = route.getRouteContext().getCamelContext().getComponent("quartz2", QuartzComponent.class);
    setScheduler(quartz.getScheduler());

    // Important: do not start scheduler as QuartzComponent does that automatic
    // when CamelContext has been fully initialized and started

    if (getRouteStopGracePeriod() == 0) {
        setRouteStopGracePeriod(10000);
    }

    if (getTimeUnit() == null) {
        setTimeUnit(TimeUnit.MILLISECONDS);
    }

    // validate time options has been configured
    if ((getRouteStartDate() == null) && (getRouteStopDate() == null) && (getRouteSuspendDate() == null) && (getRouteResumeDate() == null)) {
        throw new IllegalArgumentException("Scheduled Route Policy for route {} has no start/stop/suspend/resume times specified");
    }

    registerRouteToScheduledRouteDetails(route);
    if (getRouteStartDate() != null) {
        scheduleRoute(Action.START, route);
    }
    if (getRouteStopDate() != null) {
        scheduleRoute(Action.STOP, route);
    }

    if (getRouteSuspendDate() != null) {
        scheduleRoute(Action.SUSPEND, route);
    }
    if (getRouteResumeDate() != null) {
        scheduleRoute(Action.RESUME, route);
    }
}
 

开发者ID:HydAu,
项目名称:Camel,
代码行数:36,
代码来源:SimpleScheduledRoutePolicy.java

示例8: scheduleRoute

点赞 2

import org.apache.camel.component.quartz2.QuartzComponent; //导入依赖的package包/类
public void scheduleRoute(Action action, Route route) throws Exception {
    JobDetail jobDetail = createJobDetail(action, route);
    Trigger trigger = createTrigger(action, route);
    updateScheduledRouteDetails(action, jobDetail, trigger, route);
    
    loadCallbackDataIntoSchedulerContext(jobDetail, action, route);

    boolean isClustered = route.getRouteContext().getCamelContext().getComponent("quartz2", QuartzComponent.class).isClustered();
    if (isClustered) {
        // check to see if the same job has already been setup through another node of the cluster
        JobDetail existingJobDetail = getScheduler().getJobDetail(jobDetail.getKey());
        if (jobDetail.equals(existingJobDetail)) {
            if (LOG.isInfoEnabled()) {
                LOG.info("Skipping to schedule the job: {} for action: {} on route {} as the job: {} already existing inside the cluster",
                         new Object[] {jobDetail.getKey(), action, route.getId(), existingJobDetail.getKey()});
            }

            // skip scheduling the same job again as one is already existing for the same routeId and action
            return;
        }
    }

    getScheduler().scheduleJob(jobDetail, trigger);

    if (LOG.isInfoEnabled()) {
        LOG.info("Scheduled trigger: {} for action: {} on route {}", new Object[]{trigger.getKey(), action, route.getId()});
    }
}
 

开发者ID:HydAu,
项目名称:Camel,
代码行数:29,
代码来源:ScheduledRoutePolicy.java

示例9: doOnInit

点赞 2

import org.apache.camel.component.quartz2.QuartzComponent; //导入依赖的package包/类
protected void doOnInit(Route route) throws Exception {
    QuartzComponent quartz = route.getRouteContext().getCamelContext().getComponent("quartz2", QuartzComponent.class);
    setScheduler(quartz.getScheduler());

    // Important: do not start scheduler as QuartzComponent does that automatic
    // when CamelContext has been fully initialized and started

    if (getRouteStopGracePeriod() == 0) {
        setRouteStopGracePeriod(10000);
    }

    if (getTimeUnit() == null) {
        setTimeUnit(TimeUnit.MILLISECONDS);
    }

    // validate time options has been configured
    if ((getRouteStartTime() == null) && (getRouteStopTime() == null) && (getRouteSuspendTime() == null) && (getRouteResumeTime() == null)) {
        throw new IllegalArgumentException("Scheduled Route Policy for route {} has no start/stop/suspend/resume times specified");
    }

    registerRouteToScheduledRouteDetails(route);
    if (getRouteStartTime() != null) {
        scheduleRoute(Action.START, route);
    }
    if (getRouteStopTime() != null) {
        scheduleRoute(Action.STOP, route);
    }

    if (getRouteSuspendTime() != null) {
        scheduleRoute(Action.SUSPEND, route);
    }
    if (getRouteResumeTime() != null) {
        scheduleRoute(Action.RESUME, route);
    }
}
 

开发者ID:HydAu,
项目名称:Camel,
代码行数:36,
代码来源:CronScheduledRoutePolicy.java

示例10: configureQuartzComponent

点赞 2

import org.apache.camel.component.quartz2.QuartzComponent; //导入依赖的package包/类
@Bean
@ConditionalOnClass(CamelContext.class)
@ConditionalOnMissingBean(QuartzComponent.class)
public QuartzComponent configureQuartzComponent(CamelContext camelContext,
        QuartzComponentConfiguration configuration) throws Exception {
    QuartzComponent component = new QuartzComponent();
    component.setCamelContext(camelContext);
    Map<String, Object> parameters = new HashMap<>();
    IntrospectionSupport.getProperties(configuration, parameters, null,
            false);
    IntrospectionSupport.setProperties(camelContext,
            camelContext.getTypeConverter(), component, parameters);
    return component;
}
 

开发者ID:HydAu,
项目名称:Camel,
代码行数:15,
代码来源:QuartzComponentAutoConfiguration.java

示例11: testScheduledStartRoutePolicy

点赞 2

import org.apache.camel.component.quartz2.QuartzComponent; //导入依赖的package包/类
@Test
public void testScheduledStartRoutePolicy() throws Exception {
    MockEndpoint success = context.getEndpoint("mock:success", MockEndpoint.class);        
    success.expectedMessageCount(1);
    
    context.getComponent("quartz2", QuartzComponent.class).setPropertiesFile("org/apache/camel/routepolicy/quartz2/myquartz.properties");
    context.addRoutes(new RouteBuilder() {
        public void configure() {   
            SimpleScheduledRoutePolicy policy = new SimpleScheduledRoutePolicy();
            long startTime = System.currentTimeMillis() + 3000L;
            policy.setRouteStartDate(new Date(startTime));
            policy.setRouteStartRepeatCount(1);
            policy.setRouteStartRepeatInterval(3000);
            
            from("direct:start")
                .routeId("test")
                .routePolicy(policy)
                .to("mock:success");
        }
    });
    context.start();
    context.stopRoute("test", 1000, TimeUnit.MILLISECONDS);
    
    Thread.sleep(5000);
    assertTrue(context.getRouteStatus("test") == ServiceStatus.Started);
    template.sendBody("direct:start", "Ready or not, Here, I come");

    context.getComponent("quartz2", QuartzComponent.class).stop();
    success.assertIsSatisfied();
}
 

开发者ID:HydAu,
项目名称:Camel,
代码行数:31,
代码来源:SimpleScheduledRoutePolicyTest.java

示例12: testScheduledStopRoutePolicy

点赞 2

import org.apache.camel.component.quartz2.QuartzComponent; //导入依赖的package包/类
@Test
public void testScheduledStopRoutePolicy() throws Exception {
    context.getComponent("quartz2", QuartzComponent.class).setPropertiesFile("org/apache/camel/routepolicy/quartz2/myquartz.properties");
    context.addRoutes(new RouteBuilder() {
        public void configure() {
            SimpleScheduledRoutePolicy policy = new SimpleScheduledRoutePolicy();
            long startTime = System.currentTimeMillis() + 3000;
            policy.setRouteStopDate(new Date(startTime));
            policy.setRouteStopRepeatCount(1);
            policy.setRouteStopRepeatInterval(3000);
            
            from("direct:start")
                .routeId("test")
                .routePolicy(policy)
                .to("mock:unreachable");
        }
    });
    context.start();
    
    Thread.sleep(4000);

    assertTrue(context.getRouteStatus("test") == ServiceStatus.Stopped);

    boolean consumerStopped = false;
    try {
        template.sendBody("direct:start", "Ready or not, Here, I come");
    } catch (CamelExecutionException e) {
        consumerStopped = true;
    }    
    assertTrue(consumerStopped);
    context.getComponent("quartz2", QuartzComponent.class).stop();
}
 

开发者ID:HydAu,
项目名称:Camel,
代码行数:33,
代码来源:SimpleScheduledRoutePolicyTest.java

示例13: testScheduledSuspendRoutePolicy

点赞 2

import org.apache.camel.component.quartz2.QuartzComponent; //导入依赖的package包/类
@Test
public void testScheduledSuspendRoutePolicy() throws Exception {
    context.getComponent("quartz2", QuartzComponent.class).setPropertiesFile("org/apache/camel/routepolicy/quartz2/myquartz.properties");
    context.addRoutes(new RouteBuilder() {
        public void configure() {
            SimpleScheduledRoutePolicy policy = new SimpleScheduledRoutePolicy();
            long startTime = System.currentTimeMillis() + 3000L;
            policy.setRouteSuspendDate(new Date(startTime));
            policy.setRouteSuspendRepeatCount(1);
            policy.setRouteSuspendRepeatInterval(3000);
            
            from("direct:start")
                .routeId("test")
                .routePolicy(policy)
                .to("mock:unreachable");
        } 
    });
    context.start();
    
    Thread.sleep(4000);

    boolean consumerSuspended = false;
    try {
        template.sendBody("direct:start", "Ready or not, Here, I come");
    } catch (CamelExecutionException e) {
        consumerSuspended = true;
    }        
    assertTrue(consumerSuspended);
    context.getComponent("quartz2", QuartzComponent.class).stop();
}
 

开发者ID:HydAu,
项目名称:Camel,
代码行数:31,
代码来源:SimpleScheduledRoutePolicyTest.java

示例14: testScheduledResumeRoutePolicy

点赞 2

import org.apache.camel.component.quartz2.QuartzComponent; //导入依赖的package包/类
@Test
public void testScheduledResumeRoutePolicy() throws Exception {
    MockEndpoint success = context.getEndpoint("mock:success", MockEndpoint.class);
    success.expectedMessageCount(1);
    
    context.getComponent("quartz2", QuartzComponent.class).setPropertiesFile("org/apache/camel/routepolicy/quartz2/myquartz.properties");
    context.addRoutes(new RouteBuilder() {
        public void configure() {
            SimpleScheduledRoutePolicy policy = new SimpleScheduledRoutePolicy();
            long startTime = System.currentTimeMillis() + 3000L;
            policy.setRouteResumeDate(new Date(startTime));
            policy.setRouteResumeRepeatCount(1);
            policy.setRouteResumeRepeatInterval(3000);
            
            from("direct:start")
                .routeId("test")
                .routePolicy(policy)
                .to("mock:success");
        } 
    });
    context.start();

    ServiceHelper.suspendService(context.getRoute("test").getConsumer());
    try {
        template.sendBody("direct:start", "Ready or not, Here, I come");
        fail("Should have thrown an exception");
    } catch (CamelExecutionException e) {
        LOG.debug("Consumer successfully suspended");
    } 
    
    Thread.sleep(4000);
    template.sendBody("direct:start", "Ready or not, Here, I come");
    
    context.getComponent("quartz2", QuartzComponent.class).stop();
    success.assertIsSatisfied();
}
 

开发者ID:HydAu,
项目名称:Camel,
代码行数:37,
代码来源:SimpleScheduledRoutePolicyTest.java

示例15: testScheduledSuspendAndResumeRoutePolicy

点赞 2

import org.apache.camel.component.quartz2.QuartzComponent; //导入依赖的package包/类
@Test
public void testScheduledSuspendAndResumeRoutePolicy() throws Exception {
    MockEndpoint success = context.getEndpoint("mock:success", MockEndpoint.class);
    success.expectedMessageCount(1);
    
    context.getComponent("quartz2", QuartzComponent.class).setPropertiesFile("org/apache/camel/routepolicy/quartz2/myquartz.properties");
    context.addRoutes(new RouteBuilder() {
        public void configure() {
            SimpleScheduledRoutePolicy policy = new SimpleScheduledRoutePolicy();
            long suspendTime = System.currentTimeMillis() + 1000L;
            policy.setRouteSuspendDate(new Date(suspendTime));
            policy.setRouteSuspendRepeatCount(0);
            policy.setRouteSuspendRepeatInterval(3000);
            long resumeTime = System.currentTimeMillis() + 4000L;
            policy.setRouteResumeDate(new Date(resumeTime));
            policy.setRouteResumeRepeatCount(1);
            policy.setRouteResumeRepeatInterval(3000);
            
            from("direct:start")
                .routeId("test")
                .routePolicy(policy)
                .to("mock:success");
        } 
    });
    context.start();
    Thread.sleep(1000);
    
    try {
        template.sendBody("direct:start", "Ready or not, Here, I come");
        fail("Should have thrown an exception");
    } catch (CamelExecutionException e) {
        LOG.debug("Consumer successfully suspended");
    } 
    
    Thread.sleep(4000);
    template.sendBody("direct:start", "Ready or not, Here, I come");
    
    context.getComponent("quartz2", QuartzComponent.class).stop();
    success.assertIsSatisfied();
}
 

开发者ID:HydAu,
项目名称:Camel,
代码行数:41,
代码来源:SimpleScheduledRoutePolicyTest.java

示例16: testScheduledSuspendAndRestartPolicy

点赞 2

import org.apache.camel.component.quartz2.QuartzComponent; //导入依赖的package包/类
@Test
public void testScheduledSuspendAndRestartPolicy() throws Exception {
    MockEndpoint success = context.getEndpoint("mock:success", MockEndpoint.class);
    success.expectedMessageCount(1);
    
    context.getComponent("quartz2", QuartzComponent.class).setPropertiesFile("org/apache/camel/routepolicy/quartz2/myquartz.properties");
    context.addRoutes(new RouteBuilder() {
        public void configure() {
            SimpleScheduledRoutePolicy policy = new SimpleScheduledRoutePolicy();
            long suspendTime = System.currentTimeMillis() + 1000L;
            policy.setRouteSuspendDate(new Date(suspendTime));
            policy.setRouteSuspendRepeatCount(0);
            long startTime = System.currentTimeMillis() + 4000L;
            policy.setRouteStartDate(new Date(startTime));
            policy.setRouteResumeRepeatCount(1);
            policy.setRouteResumeRepeatInterval(3000);
            
            from("direct:start")
                .routeId("test")
                .routePolicy(policy)
                .to("mock:success");
        } 
    });
    context.start();
    Thread.sleep(1000);
    
    try {
        template.sendBody("direct:start", "Ready or not, Here, I come");
        fail("Should have thrown an exception");
    } catch (CamelExecutionException e) {
        LOG.debug("Consumer successfully suspended");
    } 
    
    Thread.sleep(4000);
    template.sendBody("direct:start", "Ready or not, Here, I come");
    
    context.getComponent("quartz2", QuartzComponent.class).stop();
    success.assertIsSatisfied();
}
 

开发者ID:HydAu,
项目名称:Camel,
代码行数:40,
代码来源:SimpleScheduledRoutePolicyTest.java

示例17: testScheduledStartRoutePolicyWithTwoRoutes

点赞 2

import org.apache.camel.component.quartz2.QuartzComponent; //导入依赖的package包/类
@Test
public void testScheduledStartRoutePolicyWithTwoRoutes() throws Exception {
    MockEndpoint success1 = context.getEndpoint("mock:success1", MockEndpoint.class);
    MockEndpoint success2 = context.getEndpoint("mock:success2", MockEndpoint.class);
    success1.expectedMessageCount(1);
    success2.expectedMessageCount(1);

    context.getComponent("quartz2", QuartzComponent.class).setPropertiesFile("org/apache/camel/routepolicy/quartz2/myquartz.properties");

    context.addRoutes(new RouteBuilder() {
        public void configure() {
            CronScheduledRoutePolicy policy = new CronScheduledRoutePolicy();
            policy.setRouteStartTime("*/3 * * * * ?");

            from("direct:start1")
                .routeId("test1")
                .routePolicy(policy)
                .to("mock:success1");

            from("direct:start2")
                .routeId("test2")
                .routePolicy(policy)
                .to("mock:success2");
        }
    });
    context.start();
    context.stopRoute("test1", 1000, TimeUnit.MILLISECONDS);
    context.stopRoute("test2", 1000, TimeUnit.MILLISECONDS);

    Thread.sleep(5000);
    assertTrue(context.getRouteStatus("test1") == ServiceStatus.Started);
    assertTrue(context.getRouteStatus("test2") == ServiceStatus.Started);
    template.sendBody("direct:start1", "Ready or not, Here, I come");
    template.sendBody("direct:start2", "Ready or not, Here, I come");

    success1.assertIsSatisfied();
    success2.assertIsSatisfied();
}
 

开发者ID:HydAu,
项目名称:Camel,
代码行数:39,
代码来源:CronScheduledRoutePolicyTest.java

示例18: testScheduledStopRoutePolicyWithTwoRoutes

点赞 2

import org.apache.camel.component.quartz2.QuartzComponent; //导入依赖的package包/类
@Test
public void testScheduledStopRoutePolicyWithTwoRoutes() throws Exception {
    context.getComponent("quartz2", QuartzComponent.class).setPropertiesFile("org/apache/camel/routepolicy/quartz2/myquartz.properties");
    context.addRoutes(new RouteBuilder() {
        public void configure() {
            CronScheduledRoutePolicy policy = new CronScheduledRoutePolicy();
            policy.setRouteStopTime("*/3 * * * * ?");
            policy.setRouteStopGracePeriod(0);
            policy.setTimeUnit(TimeUnit.MILLISECONDS);

            from("direct:start1")
                .routeId("test1")
                .routePolicy(policy)
                .to("mock:unreachable");

            from("direct:start2")
                .routeId("test2")
                .routePolicy(policy)
                .to("mock:unreachable");
        }
    });
    context.start();

    Thread.sleep(5000);

    assertTrue(context.getRouteStatus("test1") == ServiceStatus.Stopped);
    assertTrue(context.getRouteStatus("test2") == ServiceStatus.Stopped);
}
 

开发者ID:HydAu,
项目名称:Camel,
代码行数:29,
代码来源:CronScheduledRoutePolicyTest.java

示例19: testScheduledStartRoutePolicy

点赞 2

import org.apache.camel.component.quartz2.QuartzComponent; //导入依赖的package包/类
@Test
public void testScheduledStartRoutePolicy() throws Exception {
    MockEndpoint success = context.getEndpoint("mock:success", MockEndpoint.class);
    success.expectedMessageCount(1);
    
    context.getComponent("quartz2", QuartzComponent.class).setPropertiesFile("org/apache/camel/routepolicy/quartz2/myquartz.properties");

    context.addRoutes(new RouteBuilder() {
        public void configure() {    
            CronScheduledRoutePolicy policy = new CronScheduledRoutePolicy();
            policy.setRouteStartTime("*/3 * * * * ?");
            
            from("direct:start")
                .routeId("test")
                .routePolicy(policy)
                .to("mock:success");
        }
    });
    context.start();
    context.stopRoute("test", 1000, TimeUnit.MILLISECONDS);
    
    Thread.sleep(5000);
    assertTrue(context.getRouteStatus("test") == ServiceStatus.Started);
    template.sendBody("direct:start", "Ready or not, Here, I come");

    context.getComponent("quartz2", QuartzComponent.class).stop();
    success.assertIsSatisfied();
}
 

开发者ID:HydAu,
项目名称:Camel,
代码行数:29,
代码来源:CronScheduledRoutePolicyTest.java

示例20: testScheduledResumeRoutePolicy

点赞 2

import org.apache.camel.component.quartz2.QuartzComponent; //导入依赖的package包/类
@Test
public void testScheduledResumeRoutePolicy() throws Exception {
    MockEndpoint success = context.getEndpoint("mock:success", MockEndpoint.class);
    success.expectedMessageCount(1);
    
    context.getComponent("quartz2", QuartzComponent.class).setPropertiesFile("org/apache/camel/routepolicy/quartz2/myquartz.properties");
    context.addRoutes(new RouteBuilder() {
        public void configure() {
            CronScheduledRoutePolicy policy = new CronScheduledRoutePolicy();
            policy.setRouteResumeTime("*/3 * * * * ?");
            
            from("direct:start")
                .routeId("test")
                .routePolicy(policy)
                .to("mock:success");
        } 
    });
    context.start();

    ServiceHelper.suspendService(context.getRoute("test").getConsumer());

    Thread.sleep(5000);
    assertTrue(context.getRouteStatus("test") == ServiceStatus.Started);

    template.sendBody("direct:start", "Ready or not, Here, I come");

    success.assertIsSatisfied();
}
 

开发者ID:HydAu,
项目名称:Camel,
代码行数:29,
代码来源:CronScheduledRoutePolicyTest.java

示例21: testScheduledStartAndStopRoutePolicy

点赞 2

import org.apache.camel.component.quartz2.QuartzComponent; //导入依赖的package包/类
@Test
public void testScheduledStartAndStopRoutePolicy() throws Exception {
    MockEndpoint success = context.getEndpoint("mock:success", MockEndpoint.class);        
    success.expectedMessageCount(1);
    
    context.getComponent("quartz2", QuartzComponent.class).setPropertiesFile("org/apache/camel/routepolicy/quartz2/myquartz.properties");
    context.addRoutes(new RouteBuilder() {
        public void configure() {   
            SimpleScheduledRoutePolicy policy = new SimpleScheduledRoutePolicy();
            long startTime = System.currentTimeMillis() + 3000L;
            long stopTime = System.currentTimeMillis() + 8000L;
            policy.setRouteStartDate(new Date(startTime));
            policy.setRouteStartRepeatCount(1);
            policy.setRouteStartRepeatInterval(3000);
            policy.setRouteStopDate(new Date(stopTime));
            policy.setRouteStopRepeatCount(1);
            policy.setRouteStopRepeatInterval(3000);
            
            from("direct:start")
                .routeId("test")
                .routePolicy(policy)
                .to("mock:success");
        }
    });
    context.start();
    
    Thread.sleep(5000);
    assertTrue(context.getRouteStatus("test") == ServiceStatus.Started);
    template.sendBody("direct:start", "Ready or not, Here, I come");
    Thread.sleep(5000);
    assertTrue(context.getRouteStatus("test") == ServiceStatus.Stopped);
    
    context.getComponent("quartz2", QuartzComponent.class).stop();
    success.assertIsSatisfied();
}
 

开发者ID:HydAu,
项目名称:Camel,
代码行数:36,
代码来源:SimpleScheduledCombinedRoutePolicyTest.java

示例22: boot

点赞 2

import org.apache.camel.component.quartz2.QuartzComponent; //导入依赖的package包/类
public void boot() throws Exception {
    main = new Main();

    // setup quartz component
    QuartzComponent quartz = new QuartzComponent();
    quartz.setPropertiesFile("quartz.properties");

    // add the component to Camel
    main.bind("quartz2", quartz);

    main.addRouteBuilder(new QuartzRoute("Foo"));
    main.run();
}
 

开发者ID:camelinaction,
项目名称:camelinaction2,
代码行数:14,
代码来源:ServerFoo.java

示例23: boot

点赞 2

import org.apache.camel.component.quartz2.QuartzComponent; //导入依赖的package包/类
public void boot() throws Exception {
    main = new Main();

    // setup quartz component
    QuartzComponent quartz = new QuartzComponent();
    quartz.setPropertiesFile("quartz.properties");

    // add the component to Camel
    main.bind("quartz2", quartz);

    // route which uses get/put operations
    main.addRouteBuilder(new QuartzRoute("Bar"));
    main.run();
}
 

开发者ID:camelinaction,
项目名称:camelinaction2,
代码行数:15,
代码来源:ServerBar.java

示例24: quartzComponent

点赞 2

import org.apache.camel.component.quartz2.QuartzComponent; //导入依赖的package包/类
@Bean
public QuartzComponent quartzComponent(
    @Value("${scheduler.startup-delay-seconds}") final int startupDelaySeconds) {
  final Properties quartzProperties = new Properties();
  quartzProperties.setProperty("org.quartz.plugin.shutdownhook.class",
      "org.quartz.plugins.management.ShutdownHookPlugin");
  quartzProperties.setProperty("org.quartz.plugin.shutdownhook.cleanShutdown", "true");

  final QuartzComponent component = new QuartzComponent();
  component.setEnableJmx(false);
  component.setStartDelayedSeconds(startupDelaySeconds);
  component.setProperties(quartzProperties);
  return component;
}
 

开发者ID:ewerk,
项目名称:sample_spring-boot-camel-mongo-jdk8,
代码行数:15,
代码来源:ProcessConfiguration.java

示例25: testScheduler

点赞 2

import org.apache.camel.component.quartz2.QuartzComponent; //导入依赖的package包/类
@Test
public void testScheduler() throws Exception {

    final CountDownLatch procLatch = new CountDownLatch(3);

    ClassLoader loader = QuartzIntegrationTest.class.getClassLoader();
    Class<?> sclass = loader.loadClass("org.quartz.Scheduler");
    Assert.assertNotNull("Scheduler can be loaded", sclass);

    CamelContext camelctx = new DefaultCamelContext();
    camelctx.addRoutes(new RouteBuilder() {
        @Override
        public void configure() throws Exception {
            from("quartz2://mytimer?trigger.repeatCount=3&trigger.repeatInterval=100").process(new Processor() {
                @Override
                public void process(Exchange exchange) throws Exception {
                    CamelContext context = exchange.getContext();
                    QuartzComponent comp = context.getComponent("quartz2", QuartzComponent.class);
                    Scheduler scheduler = comp.getScheduler();
                    Assert.assertNotNull("Scheduler not null", scheduler);
                    procLatch.countDown();
                }
            }).to("mock:result");
        }
    });

    camelctx.start();
    try {
        Assert.assertTrue("ProcLatch reached zero", procLatch.await(500, TimeUnit.MILLISECONDS));
    } finally {
        camelctx.stop();
    }
}
 

开发者ID:wildfly-extras,
项目名称:wildfly-camel,
代码行数:34,
代码来源:QuartzIntegrationTest.java

示例26: testManualComponentConfig

点赞 2

import org.apache.camel.component.quartz2.QuartzComponent; //导入依赖的package包/类
@Test
public void testManualComponentConfig() throws Exception {

    final CountDownLatch startLatch = new CountDownLatch(1);
    final CountDownLatch procLatch = new CountDownLatch(3);

    CamelContext camelctx = new DefaultCamelContext();
    camelctx.addComponent("quartz2", new QuartzComponent() {
        @Override
        public void onCamelContextStarted(CamelContext context, boolean alreadyStarted) throws Exception {
            super.onCamelContextStarted(context, alreadyStarted);
            if (!alreadyStarted) {
                startLatch.countDown();
            }
        }
    });

    camelctx.addRoutes(new RouteBuilder() {
        @Override
        public void configure() throws Exception {
            from("quartz2://mytimer?trigger.repeatCount=3&trigger.repeatInterval=100").process(new Processor() {
                @Override
                public void process(Exchange exchange) throws Exception {
                    procLatch.countDown();
                }
            }).to("mock:result");
        }
    });

    camelctx.start();
    try {
        Assert.assertEquals("StartLatch is zero", 0, startLatch.getCount());
        Assert.assertTrue("ProcLatch reached zero", procLatch.await(500, TimeUnit.MILLISECONDS));
    } finally {
        camelctx.stop();
    }
}
 

开发者ID:wildfly-extras,
项目名称:wildfly-camel,
代码行数:38,
代码来源:QuartzIntegrationTest.java

示例27: doStart

点赞 2

import org.apache.camel.component.quartz2.QuartzComponent; //导入依赖的package包/类
@Override
protected void doStart() throws Exception {
    ObjectHelper.notEmpty(cron, "cron", this);

    if (quartzScheduler == null) {
        // get the scheduler form the quartz component
        QuartzComponent quartz = getCamelContext().getComponent("quartz2", QuartzComponent.class);
        setQuartzScheduler(quartz.getScheduler());
    }

    JobDataMap map = new JobDataMap();
    // do not store task as its not serializable, if we have route id
    if (routeId != null) {
        map.put("routeId", routeId);
    } else {
        map.put("task", runnable);
    }
    map.put(QuartzConstants.QUARTZ_TRIGGER_TYPE, "cron");
    map.put(QuartzConstants.QUARTZ_TRIGGER_CRON_EXPRESSION, getCron());
    map.put(QuartzConstants.QUARTZ_TRIGGER_CRON_TIMEZONE, getTimeZone().getID());

    job = JobBuilder.newJob(QuartzScheduledPollConsumerJob.class)
            .usingJobData(map)
            .build();

    // store additional information on job such as camel context etc
    QuartzHelper.updateJobDataMap(getCamelContext(), job, null);

    String id = triggerId;
    if (id == null) {
        id = "trigger-" + getCamelContext().getUuidGenerator().generateUuid();
    }

    trigger = TriggerBuilder.newTrigger()
            .withIdentity(id, triggerGroup)
            .withSchedule(CronScheduleBuilder.cronSchedule(getCron()).inTimeZone(getTimeZone()))
            .build();

    LOG.debug("Scheduling job: {} with trigger: {}", job, trigger.getKey());
    quartzScheduler.scheduleJob(job, trigger);
}
 

开发者ID:HydAu,
项目名称:Camel,
代码行数:42,
代码来源:QuartzScheduledPollConsumerScheduler.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)