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?
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");