当前位置: 首页>>代码示例>>Java>>正文


Java ServiceHelper.resumeService方法代码示例

本文整理汇总了Java中org.apache.camel.util.ServiceHelper.resumeService方法的典型用法代码示例。如果您正苦于以下问题:Java ServiceHelper.resumeService方法的具体用法?Java ServiceHelper.resumeService怎么用?Java ServiceHelper.resumeService使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.camel.util.ServiceHelper的用法示例。


在下文中一共展示了ServiceHelper.resumeService方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: startConsumer

import org.apache.camel.util.ServiceHelper; //导入方法依赖的package包/类
public boolean startConsumer(Consumer consumer) throws Exception {
    boolean resumed = ServiceHelper.resumeService(consumer);
    if (resumed) {
        log.debug("Resuming consumer {}", consumer);
    }
    return resumed;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:8,代码来源:RoutePolicySupport.java

示例2: beforePoll

import org.apache.camel.util.ServiceHelper; //导入方法依赖的package包/类
@Override
public long beforePoll(long timeout) throws Exception {
    LOG.trace("Before poll {}", getEndpoint());
    // resume or start our self
    if (!ServiceHelper.resumeService(this)) {
        ServiceHelper.startService(this);
    }

    // ensure at least timeout is as long as one poll delay
    return Math.max(timeout, getDelay());
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:12,代码来源:ScheduledPollConsumer.java

示例3: resumeRoute

import org.apache.camel.util.ServiceHelper; //导入方法依赖的package包/类
public synchronized void resumeRoute(String routeId) throws Exception {
    if (!routeSupportsSuspension(routeId)) {
        // start route if suspension is not supported
        startRoute(routeId);
        return;
    }

    RouteService routeService = routeServices.get(routeId);
    if (routeService != null) {
        resumeRouteService(routeService);
        // must resume the route as well
        Route route = getRoute(routeId);
        ServiceHelper.resumeService(route);
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:16,代码来源:DefaultCamelContext.java

示例4: doResume

import org.apache.camel.util.ServiceHelper; //导入方法依赖的package包/类
@Override
protected void doResume() throws Exception {
    ServiceHelper.resumeService(processor);
}
 
开发者ID:syndesisio,项目名称:syndesis,代码行数:5,代码来源:ComponentProxyProducer.java

示例5: testRestartManuallyLimitedPollingConsumerPollStrategy

import org.apache.camel.util.ServiceHelper; //导入方法依赖的package包/类
public void testRestartManuallyLimitedPollingConsumerPollStrategy() throws Exception {
    Exception expectedException = new Exception("Hello");

    strategy = new LimitedPollingConsumerPollStrategy();
    strategy.setLimit(3);

    final Endpoint endpoint = getMockEndpoint("mock:foo");
    MockScheduledPollConsumer consumer = new MockScheduledPollConsumer(endpoint, expectedException);
    consumer.setPollStrategy(strategy);

    consumer.start();

    consumer.run();
    assertTrue("Should still be started", consumer.isStarted());
    consumer.run();
    assertTrue("Should still be started", consumer.isStarted());
    consumer.run();
    assertTrue("Should be suspended", consumer.isSuspended());

    // now start the consumer again
    ServiceHelper.resumeService(consumer);

    consumer.run();
    assertTrue("Should still be started", consumer.isStarted());
    consumer.run();
    assertTrue("Should still be started", consumer.isStarted());
    consumer.run();
    assertTrue("Should be suspended", consumer.isSuspended());

    // now start the consumer again
    ServiceHelper.resumeService(consumer);
    // and let it succeed
    consumer.setExceptionToThrowOnPoll(null);
    consumer.run();
    assertTrue("Should still be started", consumer.isStarted());
    consumer.run();
    assertTrue("Should still be started", consumer.isStarted());
    consumer.run();
    assertTrue("Should still be started", consumer.isStarted());
    consumer.run();
    assertTrue("Should still be started", consumer.isStarted());

    consumer.stop();
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:45,代码来源:LimitedPollingConsumerPollStrategyTest.java

示例6: testSuspendResume

import org.apache.camel.util.ServiceHelper; //导入方法依赖的package包/类
public void testSuspendResume() throws Exception {
    MockEndpoint mock = getMockEndpoint("mock:bar");
    mock.expectedMessageCount(1);

    template.sendBody("seda:foo", "A");

    mock.assertIsSatisfied();

    assertEquals("Started", context.getRouteStatus("foo").name());
    assertEquals("Started", context.getRouteStatus("bar").name());

    // suspend bar consumer (not the route)
    SedaConsumer consumer = (SedaConsumer) context.getRoute("bar").getConsumer();

    ServiceHelper.suspendService(consumer);
    assertEquals("Suspended", consumer.getStatus().name());

    // send a message to the route but the consumer is suspended
    // so it should not route it
    resetMocks();
    mock.expectedMessageCount(0);

    // wait a bit to ensure consumer is suspended, as it could be in a poll mode where
    // it would poll and route (there is a little slack (up till 1 sec) before suspension is empowered)
    Thread.sleep(2000);

    template.sendBody("seda:foo", "B");
    // wait 2 sec to ensure seda consumer thread would have tried to poll otherwise
    mock.assertIsSatisfied(2000);

    // resume consumer
    resetMocks();
    mock.expectedMessageCount(1);

    // resume bar consumer (not the route)
    ServiceHelper.resumeService(consumer);
    assertEquals("Started", consumer.getStatus().name());

    // the message should be routed now
    mock.assertIsSatisfied();
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:42,代码来源:SedaConsumerSuspendResumeTest.java

示例7: doResume

import org.apache.camel.util.ServiceHelper; //导入方法依赖的package包/类
@Override
protected void doResume() throws Exception {
    ServiceHelper.resumeService(nettyServerBootstrapFactory);
    super.doResume();
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:6,代码来源:NettyConsumer.java

示例8: testSuspendResume

import org.apache.camel.util.ServiceHelper; //导入方法依赖的package包/类
@Test
public void testSuspendResume() throws Exception {
    final MockEndpoint mock = getMockEndpoint("mock:bar");
    mock.expectedMessageCount(1);

    template.sendBody("disruptor:foo", "A");

    mock.assertIsSatisfied();

    assertEquals("Started", context.getRouteStatus("foo").name());
    assertEquals("Started", context.getRouteStatus("bar").name());

    // suspend bar consumer (not the route)
    final DisruptorConsumer consumer = (DisruptorConsumer)context.getRoute("bar").getConsumer();

    ServiceHelper.suspendService(consumer);
    assertEquals("Suspended", consumer.getStatus().name());

    // send a message to the route but the consumer is suspended
    // so it should not route it
    resetMocks();
    mock.expectedMessageCount(0);

    // wait a bit to ensure consumer is suspended, as it could be in a poll mode where
    // it would poll and route (there is a little slack (up till 1 sec) before suspension is empowered)
    Thread.sleep(2000);

    template.sendBody("disruptor:foo", "B");
    // wait 2 sec to ensure disruptor consumer thread would have tried to poll otherwise
    mock.assertIsSatisfied(2000);

    // resume consumer
    resetMocks();
    mock.expectedMessageCount(1);

    // resume bar consumer (not the route)
    ServiceHelper.resumeService(consumer);
    assertEquals("Started", consumer.getStatus().name());

    // the message should be routed now
    mock.assertIsSatisfied();
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:43,代码来源:DisruptorConsumerSuspendResumeTest.java


注:本文中的org.apache.camel.util.ServiceHelper.resumeService方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。