You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Robert Thullner <rt...@gmx.at> on 2008/02/26 20:51:32 UTC

Update CamelContext

Hi

I am using ActiveMQ and Camel for some little projects. All my Camel routes
are defined in a Java Class with a main method. When running the class the
context.start() method starts all my routes. After that I start my Java
programs which do some messaging.

My question is if there are some methods existing so that I could update my
CamelContext without stopping it. When I have to change a rule I usually
stop my class where all routes are defined, update the routes and then start
it again. I would like to avoid this by updating the context without
stopping the class. Is there some method to achieve this?

Thanks for a reply, 
Robert
-- 
View this message in context: http://www.nabble.com/Update-CamelContext-tp15678272s22882p15678272.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Update CamelContext

Posted by Hadrian Zbarcea <hz...@gmail.com>.
Hi Robert,

This is not possible yet.  I think there is a JIRA for this already.

Regards,
Hadrian

On Feb 26, 2008, at 2:51 PM, Robert Thullner wrote:

>
> Hi
>
> I am using ActiveMQ and Camel for some little projects. All my Camel  
> routes
> are defined in a Java Class with a main method. When running the  
> class the
> context.start() method starts all my routes. After that I start my  
> Java
> programs which do some messaging.
>
> My question is if there are some methods existing so that I could  
> update my
> CamelContext without stopping it. When I have to change a rule I  
> usually
> stop my class where all routes are defined, update the routes and  
> then start
> it again. I would like to avoid this by updating the context without
> stopping the class. Is there some method to achieve this?
>
> Thanks for a reply,
> Robert
> -- 
> View this message in context: http://www.nabble.com/Update-CamelContext-tp15678272s22882p15678272.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>


Re: Update CamelContext

Posted by "mark.van.der.voort" <ma...@acm.org>.
I've put together a crude mechanism for starting/stopping routes by the name
of their endpoint.  I do agree however that adding/deleting is probably a
nicer way of dealing with state.

I had to patch two classes in the Camel library. 
The EventdrivenConsumerRoute has to retain its consumer so that addServices
(and hence ServicesForRoute) always returns the same answer. I need this to
actually get at the registered consumer for a route. 
This patch may affect other portions of Camel that I am not yet aware of.

The second one is related to state management within the ServiceSupport
class. Here in the start method the states stopping and stopped are now
explicitly set to false. IMO this reflects the intention more clearly
anyway.

Finding routes by name boils down to crude lookup. 
>From the context you can easily extract both a Map name -> uri and a map
uri->route. Together they give
you a mapping name -> route. I don't think there is an easier way right now.

It was a long shot but shutting down a JmsEndpoint nicely shuts down all the
processing (or so it seems). Restarting an endpoint required patching the
ServiceSupport class. 

I've attached the code right here.
http://www.nabble.com/file/p21743159/ContextEnricher.java
ContextEnricher.java 
http://www.nabble.com/file/p21743159/ServiceSupport.java ServiceSupport.java 
http://www.nabble.com/file/p21743159/EventDrivenConsumerRoute.java
EventDrivenConsumerRoute.java 


James.Strachan wrote:
> 
> On 27/02/2008, Robert Thullner <rt...@gmx.at> wrote:
>>
>>
>>
>>  James.Strachan wrote:
>>  >
>>  >
>>  > Adding new routes is supported today. The main thing missing right now
>>  > is to be able to easily stop/delete existing routes.
>>  >
>>  >
>>  >
>>
>>
>> Can this just be done by writing a new Java class that contains the
>> routes
>>  and then starting the class or is there some special procedure to
>> achieve
>>  it?
> 
> Whenever you like you can call
> 
> camelContext.addRoutes(someRouteBuilder);
> 
> we just don't have an easy way yet to stop routes derived from a route
> builder
> 
> -- 
> James
> -------
> http://macstrac.blogspot.com/
> 
> Open Source Integration
> http://open.iona.com
> 
> 

-- 
View this message in context: http://www.nabble.com/Update-CamelContext-tp15678272s22882p21743159.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Update CamelContext

Posted by James Strachan <ja...@gmail.com>.
On 27/02/2008, Robert Thullner <rt...@gmx.at> wrote:
>
>
>
>  James.Strachan wrote:
>  >
>  >
>  > Adding new routes is supported today. The main thing missing right now
>  > is to be able to easily stop/delete existing routes.
>  >
>  >
>  >
>
>
> Can this just be done by writing a new Java class that contains the routes
>  and then starting the class or is there some special procedure to achieve
>  it?

Whenever you like you can call

camelContext.addRoutes(someRouteBuilder);

we just don't have an easy way yet to stop routes derived from a route builder

-- 
James
-------
http://macstrac.blogspot.com/

Open Source Integration
http://open.iona.com

Re: Update CamelContext

Posted by Robert Thullner <rt...@gmx.at>.


James.Strachan wrote:
> 
> 
> Adding new routes is supported today. The main thing missing right now
> is to be able to easily stop/delete existing routes.
> 
> 
> 

Can this just be done by writing a new Java class that contains the routes
and then starting the class or is there some special procedure to achieve
it?

Greetings,
Robert
-- 
View this message in context: http://www.nabble.com/Update-CamelContext-tp15678272s22882p15708363.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Update CamelContext

Posted by James Strachan <ja...@gmail.com>.
On 26/02/2008, Robert Thullner <rt...@gmx.at> wrote:
>  James.Strachan wrote:
>  >
>  > Just out of interest what kind of updates are you doing? e.g. changing
>  > the Java class or spring.xml files?
>  >
>  >
>
> Thanks for the quick reply,
>
>  my updates would be rather simple. I would like to add new routes (router,
>  splitter, aggregator,...) on the fly, as new applications are added to the
>  messaging infrastructure or just renaming some queue names.

Adding new routes is supported today. The main thing missing right now
is to be able to easily stop/delete existing routes.


-- 
James
-------
http://macstrac.blogspot.com/

Open Source Integration
http://open.iona.com

Re: Update CamelContext

Posted by Robert Thullner <rt...@gmx.at>.

James.Strachan wrote:
> 
> Just out of interest what kind of updates are you doing? e.g. changing
> the Java class or spring.xml files?
> 
> 

Thanks for the quick reply, 

my updates would be rather simple. I would like to add new routes (router,
splitter, aggregator,...) on the fly, as new applications are added to the
messaging infrastructure or just renaming some queue names.

Greetings,
Robert
-- 
View this message in context: http://www.nabble.com/Update-CamelContext-tp15678272s22882p15699847.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Update CamelContext

Posted by James Strachan <ja...@gmail.com>.
On 26/02/2008, Robert Thullner <rt...@gmx.at> wrote:
>
>  Hi
>
>  I am using ActiveMQ and Camel for some little projects. All my Camel routes
>  are defined in a Java Class with a main method. When running the class the
>  context.start() method starts all my routes. After that I start my Java
>  programs which do some messaging.
>
>  My question is if there are some methods existing so that I could update my
>  CamelContext without stopping it. When I have to change a rule I usually
>  stop my class where all routes are defined, update the routes and then start
>  it again. I would like to avoid this by updating the context without
>  stopping the class. Is there some method to achieve this?

Just out of interest what kind of updates are you doing? e.g. changing
the Java class or spring.xml files?

If so the ServiceMix MicroKernel can auto-reload Camel routes on the
fly if you do that; providing you use either an OSGi bundle or
expanded OSGi bundle to host your camel routes.
http://servicemix.apache.org/SMX4KNL/index.html
-- 
James
-------
http://macstrac.blogspot.com/

Open Source Integration
http://open.iona.com