简体   繁体   English

Apache Camel Context删除路由定义方法

[英]Apache Camel Context Remove Route Definition methods

As part of my project requirement, I was going through the Apache Camel Docs for removing Routes from the camel context before updating it. 作为我的项目要求的一部分,我正在浏览Apache Camel Docs,以便在更新之前从camel上下文中删除路由。

Here I am confused with removeRouteDefinition which removes a route definition from the CamelContext - stopping any previously running routes and removeRoute , stopRoute which does the same work as former. 在这里,我对removeRouteDefinition感到困惑,它删除了CamelContext中的路由定义 - 停止任何以前运行的路由和removeRoutestopRoute ,它执行与前者相同的工作。

What exactly is the difference between these methods? 这些方法之间究竟有什么区别?

The main difference is, that CamelContext#removeRouteDefinition stops gracefully route, and then removes it from Context . 主要区别在于, CamelContext#removeRouteDefinition正常停止路由,然后将其从Context删除。

The method CamelContext#removeRoute can remove only stopped route. CamelContext#removeRoute方法只能删除已停止的路由。 If you try to remove running route, the method returns false and nothing happens. 如果您尝试删除正在运行的路由,则该方法返回false并且没有任何反应。

So these two snippets are equivalents: 所以这两个片段是等价的:

removeRouteDefinition removeRouteDefinition

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

removeRoute removeRoute

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

As you can see from the documentation 正如您从文档中看到的那样

void removeRouteDefinition(RouteDefinition routeDefinition)

takes a RouteDefinition object as the argument. 将RouteDefinition对象作为参数。 Where as 在哪里

boolean removeRoute(String routeId) throws Exception

takes a routeId. 采取routeId。

Also another important thing is removeRouteDefinition is deprecated. 另外一个重要的事情是不推荐使用removeRouteDefinition

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

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