You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Raman Gupta <ro...@gmail.com> on 2011/10/31 23:13:32 UTC

Camel + Peaberry on Karaf

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

Re: Camel + Peaberry on Karaf

Posted by Willem Jiang <wi...@gmail.com>.
Because current other camel bundle doesn't need it, as the camel-spring 
and camel-blueprint has it own private page.
But if you want to use the OsigDefaultCamelContext yourself, you need 
to install that bundle.

Maybe we should rethink to reuse this bundle package in camel-spring 
and camel-blueprint.
  
On Wed Nov  2 09:55:57 2011, Raman Gupta wrote:
> On 11/01/2011 09:07 PM, Willem Jiang wrote:
>> camel-spring and camel-blueprint embed the OsgiDefaultCamelContext in
>> their bundle to avoid the bundle start sequence issue.
>> If you want to use the OsgiDefaultCamelContext, you may consider to
>> use the camel-core-osgi bundle directly.
>
> That is what I am doing. But is there a reason camel-core-osgi is not
> listed in the camel features.xml? Or is it just an oversight?
>



-- 
Willem
----------------------------------
FuseSource
Web: http://www.fusesource.com
Blog:    http://willemjiang.blogspot.com (English)
         http://jnn.javaeye.com (Chinese)
Twitter: willemjiang 
Weibo: willemjiang 


Re: Camel + Peaberry on Karaf

Posted by Raman Gupta <ro...@gmail.com>.
On 11/01/2011 09:07 PM, Willem Jiang wrote:
> camel-spring and camel-blueprint embed the OsgiDefaultCamelContext in
> their bundle to avoid the bundle start sequence issue.
> If you want to use the OsgiDefaultCamelContext, you may consider to
> use the camel-core-osgi bundle directly.

That is what I am doing. But is there a reason camel-core-osgi is not
listed in the camel features.xml? Or is it just an oversight?

Re: Camel + Peaberry on Karaf

Posted by Willem Jiang <wi...@gmail.com>.
camel-spring and camel-blueprint embed the OsgiDefaultCamelContext in 
their bundle to avoid the bundle start sequence issue.
If you want to use the OsgiDefaultCamelContext, you may consider to use 
the camel-core-osgi bundle directly.

On Tue Nov  1 23:19:44 2011, Raman Gupta wrote:
> 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.
>


-- 
Willem
----------------------------------
FuseSource
Web: http://www.fusesource.com
Blog:    http://willemjiang.blogspot.com (English)
          http://jnn.javaeye.com (Chinese)
Twitter: willemjiang
Weibo: willemjiang

Re: Camel + Peaberry on Karaf

Posted by Raman Gupta <ro...@gmail.com>.
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
> 

Re: Camel + Peaberry on Karaf

Posted by Jean-Baptiste Onofré <jb...@nanthrax.net>.
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

-- 
Jean-Baptiste Onofré
jbonofre@apache.org
http://blog.nanthrax.net
Talend - http://www.talend.com