我需要根據某些條件來限制添加到駱駝上下文的特定路由。試過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)如何? –