In your route definition add the .noAutoStartup() part like this:
from('direct:foo').routeId('myRoute').noAutoStartup()....In BootStrap.groovy's init closure add the following code:
import org.codehaus.groovy.grails.web.context.* [...] def ctx = ServletContextHolder.servletContext.getAttribute(GrailsApplicationAttributes.APPLICATION_CONTEXT) ctx.camelContext.startRoute('myRoute')This will give you the possibility to start and even stop a route anytime you want.
You can read more on this topic on fusesource.com.
I hope this will help someone :)
7 comments:
"from('direct:foo').routeId('myRoute').noAutoStart()"
should probably be
"from('direct:foo').routeId('myRoute').noAutoStartup()"
:)
"from('direct:foo').routeId('myRoute').noAutoStart()"
should probably be
"from('direct:foo').routeId('myRoute').noAutoStartup()"
:)
Corrected. Thanks!
is here an argument this should be set by default, or with a config option in the grails-routing-plugin? It could add noAutoStart(), and start all routes at the appropriate time
@Alex This plugin tries to be as close to Apache Camel as possible so that when someone switches from pure Java to Grails they find that using Camel here and there is just the same. Also at the same time when we don't change to much to how Camel works we can still rely on the original Apache Camel documentation :)
Hi Matthias, Blogger just ate a long response I put but here it is in short:
* it would be great if this plugin did not have surprising behaviour like that outlined
* if it does have this behaviour, it would be great if it was on the grails.org FAQ page for the plugin
* to access CamelContext in BootStrap.init(), the simpler way is to declare `def camelContext` as a class property
@Alex You are right. I'll have to work on both the docs and the unexpected behavior. Could you post a ticket so that it will not be forgotten?
Post a Comment