繁体   English   中英

Apache Camel Context删除路由定义方法

[英]Apache Camel Context Remove Route Definition methods

作为我的项目要求的一部分,我正在浏览Apache Camel Docs,以便在更新之前从camel上下文中删除路由。

在这里,我对removeRouteDefinition感到困惑,它删除了CamelContext中的路由定义 - 停止任何以前运行的路由和removeRoutestopRoute ,它执行与前者相同的工作。

这些方法之间究竟有什么区别?

主要区别在于, CamelContext#removeRouteDefinition正常停止路由,然后将其从Context删除。

CamelContext#removeRoute方法只能删除已停止的路由。 如果您尝试删除正在运行的路由,则该方法返回false并且没有任何反应。

所以这两个片段是等价的:

removeRouteDefinition

getContext().removeRouteDefinition(getContext().getRouteDefinition("routeId"));

removeRoute

getContext().stopRoute("routeId");
getContext().removeRoute("routeId");

正如您从文档中看到的那样

void removeRouteDefinition(RouteDefinition routeDefinition)

将RouteDefinition对象作为参数。 在哪里

boolean removeRoute(String routeId) throws Exception

采取routeId。

另外一个重要的事情是不推荐使用removeRouteDefinition

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM