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