Apache Camel Context Remove Route Definition methods

USM :

As part of my project requirement, I was going through the Apache Camel Docs for removing Routes from the camel context before updating it.

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.

What exactly is the difference between these methods?

Bedla :

The main difference is, that CamelContext#removeRouteDefinition stops gracefully route, and then removes it from Context.

The method CamelContext#removeRoute can remove only stopped route. If you try to remove running route, the method returns false and nothing happens.

So these two snippets are equivalents:

removeRouteDefinition

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

removeRoute

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

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=92233&siteId=1