本文整理汇总了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;
}
示例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());
}
示例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);
}
}
示例4: doResume
import org.apache.camel.util.ServiceHelper; //导入方法依赖的package包/类
@Override
protected void doResume() throws Exception {
ServiceHelper.resumeService(processor);
}
示例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();
}
示例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();
}
示例7: doResume
import org.apache.camel.util.ServiceHelper; //导入方法依赖的package包/类
@Override
protected void doResume() throws Exception {
ServiceHelper.resumeService(nettyServerBootstrapFactory);
super.doResume();
}
示例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();
}