You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by gnanda1 <gi...@hotmail.com> on 2010/07/16 03:30:14 UTC

Stopping and removing a route programmatically

Hi All,
I have created a temporary route reading messages from a queue. I created it
programtically by using
camelContext.addRoutes(builder);
camelContext.startRoute(id);

where builder ->  is my routebuilder definition 
id-> is routeid of the route

I would like stop and remove this route programmatically.
I tried  as below
camelContext.stopRoute(id);
RouteDefinition routedefinition = camelContext.getRouteDefinition(id);
//routedefinition.shutdownRoute("Defer");
List<RouteDefinition> list = new ArrayList<RouteDefinition>();
list.add(routedefinition);
camelContext.removeRouteDefinitions(list);

it is stopping the route as expected.
I could see the status  from the jconsole  as "stopped" . But
removeRouteDefinition is not removing the route from the jconsole. I can see
the route is listed in jconsole.

How can I remove the temporary route programatically that I have created?
Thanks & regards
Gnanda


-- 
View this message in context: http://camel.465427.n5.nabble.com/Stopping-and-removing-a-route-programmatically-tp1223859p1223859.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Stopping and removing a route programmatically

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

I have created a ticket to see if there is something we can do in the future
https://issues.apache.org/activemq/browse/CAMEL-2975

On Mon, Jul 19, 2010 at 10:34 PM, gnanda1 <gi...@hotmail.com> wrote:
>
> Thanks Clause for the reply.
> --
> View this message in context: http://camel.465427.n5.nabble.com/Stopping-and-removing-a-route-programmatically-tp1223859p1473590.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>



-- 
Claus Ibsen
Apache Camel Committer

Author of Camel in Action: http://www.manning.com/ibsen/
Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus

Re: Stopping and removing a route programmatically

Posted by gnanda1 <gi...@hotmail.com>.
Thanks Clause for the reply. 
-- 
View this message in context: http://camel.465427.n5.nabble.com/Stopping-and-removing-a-route-programmatically-tp1223859p1473590.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Stopping and removing a route programmatically

Posted by Claus Ibsen <cl...@gmail.com>.
I think some of the JMX stuff is unregistered when CamelContext shuts
down. And hence why you still see some of it in jconsole.

For example you may stop / start routes on the fly and thus Camel only
unregister routes when it's shutdown.


On Fri, Jul 16, 2010 at 10:31 PM, gnanda1 <gi...@hotmail.com> wrote:
>
> Could someone please suggest how to remove a route from a camel context
> programatically.
>
> I am using the below code to do it. But not sure if it is working as
> expected. I could still see the route from the jconsole.
>
> List<RouteDefinition> list = new ArrayList<RouteDefinition>();
> list.add(routedefinition);
> camelContext.removeRouteDefinitions(list);
>
> Any help is appreciated.
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Stopping-and-removing-a-route-programmatically-tp1223859p1235000.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>



-- 
Claus Ibsen
Apache Camel Committer

Author of Camel in Action: http://www.manning.com/ibsen/
Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus

Re: Stopping and removing a route programmatically

Posted by gnanda1 <gi...@hotmail.com>.
Could someone please suggest how to remove a route from a camel context
programatically.

I am using the below code to do it. But not sure if it is working as
expected. I could still see the route from the jconsole.

List<RouteDefinition> list = new ArrayList<RouteDefinition>(); 
list.add(routedefinition); 
camelContext.removeRouteDefinitions(list);

Any help is appreciated.

-- 
View this message in context: http://camel.465427.n5.nabble.com/Stopping-and-removing-a-route-programmatically-tp1223859p1235000.html
Sent from the Camel - Users mailing list archive at Nabble.com.