I've played with this a bit more... things seem to work much better when the camel context and routes are in the same bundle. Then one can simply start the context on bundle activation and stop on de-activation, and the associated routes (autostart=true) are started/stopped along with the context. The way I was trying required coordination of context/route stops/starts across bundles via listeners, and getting all the context/route/bundle state combinations and transitions working.
However, now I have one context per bundle using Camel. Would there be significant overhead to having several (8-10) Camel contexts running within the JVM at once? On a related note, I used org.apache.camel.core.osgi.OsgiDefaultCamelContext to get this working. This class appears to be in two bundles, but both have small issues in camel 2.8.2: camel-core-osgi (but this is not included in the camel features.xml) camel-spring (but the org.apache.camel.core.osgi package is not exported) I see that OsgiDefaultCamelContext has been removed from camel-spring on trunk, but camel-core-osgi is still not listed in features.xml. -- Raman Gupta VIVO Systems http://vivosys.com On 11/01/2011 01:31 AM, Jean-Baptiste Onofré wrote: > Hi Raman, > > I didn't try Camel and Guice Peaberry together. > > If you perform camel:route-stop, do you see the route status changed ? > Is the behavior the same if you stop the context ? > > Regards > JB > > On 10/31/2011 11:13 PM, Raman Gupta wrote: >> Hi, I'm using camel for a project. My environment is Karaf 2.2.4, with >> Guice 3.0 (API version 1.3) and Peaberry 1.2 for service injection. >> >> Because camel-guice only supports Guice 2.0, and seems to have no >> built-in support for Peaberry, I'm rolling my own OSGi compatible >> camel environment. >> >> I'm open to structuring this in multiple ways but my general thinking >> is to have a bundle contain a shared CamelContext (which is an >> instance of OsgiDefaultCamelContext) and have other bundles contribute >> Routes to the shared CamelContext by exposing them as services, and >> when those bundles are stopped, the corresponding routes are stopped >> and removed. Does that make sense? >> >> I have managed to configure Peaberry to create an instance of >> OsgiDefaultCamelContext and register it as an OSGi service. The Karaf >> camel:list-contexts command does list the context. >> >> I have also succeeded in registering the RoutesBuilder with the >> CamelContext by calling >> >> addRoutesToCamelContext(context); >> >> in the routes bundle using the context obtained from the OSGi service >> registry. >> >> At this point the route does successfully run when the context is >> started. However, when the route bundle is stopped, the route >> continues to run, even though I call: >> >> context.stopRoute(routeId); >> context.removeRoute(routeId); >> >> during the stop (via a Peaberry @Stop annotated method). I have >> confirmed the stop method is being executed. The route continues to >> run even if the bundle containing the RoutesBuilder is uninstalled. >> >> Has anyone else successfully combined Camel and Guice Peaberry? I'd >> love some tips on getting this working. >> >> Cheers, >> Raman >
