You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by manchandap <ma...@yahoo.com> on 2014/02/06 11:08:16 UTC

Adding Routes to a running Camel Context

Respected Camel Experts,

I have a situation where in I need to add routes to a running Camel Context.
To elaborate, I have Camel (that is a camel context) running in my
production environment. A new route has been defined as XML file or Java
DSL. My query is that can I make my running camel context aware of this new
route without starting and stopping the camel context. 

Thanks and Regards
P Manchanda



--
View this message in context: http://camel.465427.n5.nabble.com/Adding-Routes-to-a-running-Camel-Context-tp5746884.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Adding Routes to a running Camel Context

Posted by lb <lb...@gmail.com>.
I did something similar, maybe not the best, in an OSGi project I was working on, I've uploaded some of the code in my sandbox repository:




https://github.com/lburgazzoli/lb-sandbox-java/tree/master/sbox-camel/src/main/java/com/github/lburgazzoli/sandbox/camel—
lb

On Thu, Feb 6, 2014 at 2:44 PM, Claus Ibsen <cl...@gmail.com> wrote:

> On Thu, Feb 6, 2014 at 12:29 PM, manchandap <ma...@yahoo.com> wrote:
>> Thanks Claus for the quick reply.
>>
>> I had checked this link. My queries:
>>
>> # Where should the following code be placed that is in the main class (that
>> runs the camel context) or some processor.
>>
> Anywhere where you want to trigger the logic that adds new routes to a
> running CamelContext.
>> /// load route from XML and add them to the existing camel context
>> InputStream is = getClass().getResourceAsStream("barRoute.xml");
>> RoutesDefinition routes = context.loadRoutesDefinition(is);
>> context.addRouteDefinitions(routes.getRoutes());/
>>
>> # Would this require restart the camel that is the camel context
>> # Can i achieve similar flexibility if I am using Java DSL to define my
>> routes
>>
> Restart is not needed. You can add/remove routes on the fly. If you
> want to update an existing route, you would need to stop and shutdown
> it first, and then add the route (updates it) and then start it.
> Yes the routes can be from XML or Java DSL. For Java DSL you can all
> just use the addRoutes method that uses a RouteBuilder
>> Thanks
>> Prince Manchanda
>>
>>
>>
>> --
>> View this message in context: http://camel.465427.n5.nabble.com/Adding-Routes-to-a-running-Camel-Context-tp5746884p5746887.html
>> Sent from the Camel - Users mailing list archive at Nabble.com.
> -- 
> Claus Ibsen
> -----------------
> Red Hat, Inc.
> Email: cibsen@redhat.com
> Twitter: davsclaus
> Blog: http://davsclaus.com
> Author of Camel in Action: http://www.manning.com/ibsen
> Make your Camel applications look hawt, try: http://hawt.io

Re: Adding Routes to a running Camel Context

Posted by Claus Ibsen <cl...@gmail.com>.
On Thu, Feb 6, 2014 at 12:29 PM, manchandap <ma...@yahoo.com> wrote:
> Thanks Claus for the quick reply.
>
> I had checked this link. My queries:
>
> # Where should the following code be placed that is in the main class (that
> runs the camel context) or some processor.
>

Anywhere where you want to trigger the logic that adds new routes to a
running CamelContext.


> /// load route from XML and add them to the existing camel context
> InputStream is = getClass().getResourceAsStream("barRoute.xml");
> RoutesDefinition routes = context.loadRoutesDefinition(is);
> context.addRouteDefinitions(routes.getRoutes());/
>
> # Would this require restart the camel that is the camel context
> # Can i achieve similar flexibility if I am using Java DSL to define my
> routes
>

Restart is not needed. You can add/remove routes on the fly. If you
want to update an existing route, you would need to stop and shutdown
it first, and then add the route (updates it) and then start it.

Yes the routes can be from XML or Java DSL. For Java DSL you can all
just use the addRoutes method that uses a RouteBuilder

> Thanks
> Prince Manchanda
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Adding-Routes-to-a-running-Camel-Context-tp5746884p5746887.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
Email: cibsen@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen
Make your Camel applications look hawt, try: http://hawt.io

Re: Adding Routes to a running Camel Context

Posted by manchandap <ma...@yahoo.com>.
Thanks Claus for the quick reply.

I had checked this link. My queries:

# Where should the following code be placed that is in the main class (that
runs the camel context) or some processor.

/// load route from XML and add them to the existing camel context
InputStream is = getClass().getResourceAsStream("barRoute.xml");
RoutesDefinition routes = context.loadRoutesDefinition(is);
context.addRouteDefinitions(routes.getRoutes());/

# Would this require restart the camel that is the camel context
# Can i achieve similar flexibility if I am using Java DSL to define my
routes

Thanks 
Prince Manchanda



--
View this message in context: http://camel.465427.n5.nabble.com/Adding-Routes-to-a-running-Camel-Context-tp5746884p5746887.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Adding Routes to a running Camel Context

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

See this page
http://camel.apache.org/loading-routes-from-xml-files.html



On Thu, Feb 6, 2014 at 11:08 AM, manchandap <ma...@yahoo.com> wrote:
> Respected Camel Experts,
>
> I have a situation where in I need to add routes to a running Camel Context.
> To elaborate, I have Camel (that is a camel context) running in my
> production environment. A new route has been defined as XML file or Java
> DSL. My query is that can I make my running camel context aware of this new
> route without starting and stopping the camel context.
>
> Thanks and Regards
> P Manchanda
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Adding-Routes-to-a-running-Camel-Context-tp5746884.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
Email: cibsen@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen
Make your Camel applications look hawt, try: http://hawt.io