本文整理汇总了Java中org.apache.camel.Route.getConsumer方法的典型用法代码示例。如果您正苦于以下问题:Java Route.getConsumer方法的具体用法?Java Route.getConsumer怎么用?Java Route.getConsumer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.camel.Route
的用法示例。
在下文中一共展示了Route.getConsumer方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: logRouteState
import org.apache.camel.Route; //导入方法依赖的package包/类
protected void logRouteState(Route route, String state) {
if (log.isInfoEnabled()) {
if (route.getConsumer() != null) {
log.info("Route: {} is {}, was consuming from: {}", new Object[]{route.getId(), state, route.getConsumer().getEndpoint()});
} else {
log.info("Route: {} is {}.", route.getId(), state);
}
}
}
示例2: onExchangeDone
import org.apache.camel.Route; //导入方法依赖的package包/类
public void onExchangeDone(Route route, Exchange exchange) {
// only stop it at first run
if (counter++ == 0) {
try {
super.stopConsumer(route.getConsumer());
} catch (Exception e) {
handleException(e);
}
}
}
示例3: onExchangeDone
import org.apache.camel.Route; //导入方法依赖的package包/类
public void onExchangeDone(Route route, Exchange exchange) {
this.consumer = route.getConsumer();
// only stop it at first run
if (counter++ == 0) {
try {
super.stopConsumer(consumer);
} catch (Exception e) {
handleException(e);
}
}
}
示例4: execute
import org.apache.camel.Route; //导入方法依赖的package包/类
@Override
public void execute(JobExecutionContext context) throws JobExecutionException {
LOG.trace("Execute job: {}", context);
CamelContext camelContext = getCamelContext(context);
Runnable task = (Runnable) context.getJobDetail().getJobDataMap().get("task");
if (task == null) {
// if not task then use the route id to lookup the consumer to be used as the task
String routeId = (String) context.getJobDetail().getJobDataMap().get("routeId");
if (routeId != null && camelContext != null) {
// find the consumer
for (Route route : camelContext.getRoutes()) {
if (route.getId().equals(routeId)) {
Consumer consumer = route.getConsumer();
if (consumer instanceof Runnable) {
task = (Runnable) consumer;
break;
}
}
}
}
}
if (task != null) {
LOG.trace("Running task: {}", task);
task.run();
}
}
示例5: onInit
import org.apache.camel.Route; //导入方法依赖的package包/类
@Override
public void onInit(Consumer consumer) {
this.consumer = consumer;
// find the route of the consumer
for (Route route : consumer.getEndpoint().getCamelContext().getRoutes()) {
if (route.getConsumer() == consumer) {
this.routeId = route.getId();
break;
}
}
}