我需要根据某些条件来限制添加到骆驼上下文的特定路由。试过RoutePolicy.onStart - >但是这个方法在启动路由后被调用。基于某些条件,禁用路由被添加到骆驼上下文
我需要一种方法来完全避免生成/添加到骆驼上下文的路线。
private List<String> eligibleRoutes;
@Override
public void onStart(Route route) {
LOGGER.info("onInit for {}", route.getId());
if (isCollectionNotEmpty(eligibleRoutes))
{
LOGGER.info("route-start eligibility for route {}", route.getId());
if (eligibleRoutes.contains(route.getId()))
{
LOGGER.info("Route-start is set to ELIGiBLE for {}", route.getId());
}else{
LOGGER.info("Route-start is set to NOT ELIGiBLE for {}", route.getId());
route.getRouteContext().getCamelContext().stopRoute(route.getId());
boolean status = route.getRouteContext().getCamelContext().removeRoute(route.getId());
return;
}
}
您是使用Spring集成还是自己创建和管理'CamelContext'?如何将路由添加到代码中的上下文中? –
使用蓝图创建camelContext和路线。我有多条路线,只有在符合条件时才需要让它们可见。 – Venkat
[基于内容的路由器](http://camel.apache.org/content-based-router.html)如何? –