You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by rwijngaa <ri...@gmail.com> on 2015/09/25 16:47:07 UTC

Recommended practices for dynamically creating and removing camel routes and camel contexts

Hi,

I have a program which creates Camel routes dynamically based on one or more
route xml files in a folder. You can also specify a context, which then will
lead to the route created in that specified camel context.

Basically this:
    CamelContext camelContext = new SpringCamelContext(applicationContext);
    camelContext.addRoutes(theNewRouteBuilder);
    ((SpringCamelContext) camelContext).setName(theContextName);
    // add same components to this new context that were also present in
default camel context
    camelContext.start();

When the route xml file is removed, i do a camelContext.stopRoute(routeId)
and a camelContext.removeRoute(routeId). If it was the last route in the
camel context i also do
a camelContext.stop().

The problem is: sometimes when i remove a route xml and the re-add it, it is
not created / visible in the cli / hawtio. I guess i'm missing something.
*So my question is: are there any recommended practices for dynamically
creating and removing camel routes and or camel contexts.*

Regards
Rino





--
View this message in context: http://camel.465427.n5.nabble.com/Recommended-practices-for-dynamically-creating-and-removing-camel-routes-and-camel-contexts-tp5771978.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Recommended practices for dynamically creating and removing camel routes and camel contexts

Posted by rwijngaa <ri...@gmail.com>.
talking to myself here ;-)

If i replace camelContext.stop() with camelContext.suspend()
and camelContext.start() with camelContext.resume() than it works fine.
I guess using  camelContext.stop() is only used for bringing the whole camel
stack down,
not to bring it up again later

Rino.





--
View this message in context: http://camel.465427.n5.nabble.com/Recommended-practices-for-dynamically-creating-and-removing-camel-routes-and-camel-contexts-tp5771978p5772154.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Recommended practices for dynamically creating and removing camel routes and camel contexts

Posted by rwijngaa <ri...@gmail.com>.
The problem arises when i stop all non-default camel contexts and recreate
them later again after a route or property is changed for example. Then all
camelContexts are gone (except the one that was in a spring xml file that
rereads the route xmls every xx-seconds).

I also got this then:
Caused by: java.lang.NullPointerException
	at
org.springframework.jms.support.JmsAccessor.createSession(JmsAccessor.java:196)
	at org.springframework.jms.core.JmsTemplate.execute(JmsTemplate.java:457)
	at
org.apache.camel.component.jms.JmsConfiguration$CamelJmsTemplate.send(JmsConfiguration.java:235)
	at org.apache.camel.component.jms.JmsProducer.doSend(JmsProducer.java:413)
	at
org.apache.camel.component.jms.JmsProducer.processInOnly(JmsProducer.java:367)
	at org.apache.camel.component.jms.JmsProducer.process(JmsProducer.java:153)




--
View this message in context: http://camel.465427.n5.nabble.com/Recommended-practices-for-dynamically-creating-and-removing-camel-routes-and-camel-contexts-tp5771978p5772131.html
Sent from the Camel - Users mailing list archive at Nabble.com.