Distributed OSGi in Fabric

The Remote Services OSGi specification describes how services registered in an OSGi framework can be transparently accessed from another OSGi framework. This is in essence a remoting capability for OSGi services. Fabric has a very fast implementation of this specification, leveraging ZooKeeper for the discovery of services.

From the user point of view, registering a service with a property service.exported.interfaces (with a value of ‘*’ or a list of classes to expose) is the only thing to do to make a service available from the outside. The Fabric DOSGi implementation will automatically detect which services have to be imported and will automatically create a proxy in the OSGi registry for those needed. This services to be imported are found through the use of Service Hooks which enable the implementation to be aware of which services are required by existing bundles. For example, if a bundle registers a ServiceListener (directly or indirectly by using Blueprint for example), the Fabric DOSGi implementation will check if there is a local service satisfying the listener and if there’s none, it will look into the ZooKeeper registry and import a matching service.

The Fabric implementation is based on the insanely fast HawtDispatch library which has a very nice support for NIO. The result is a very fast remoting mechanism for OSGi with more than 25.000 requests per second on my laptop. This remoting mechanism is actually not dependant on OSGi and external clients can also connect to a remote OSGi service provided they can find the service identifier from ZooKeeper or some other place.

A complete example can be found in the Fabric source tree at on github.

Comments

ML said…
The example is now at:

https://github.com/fusesource/fuse/tree/master/fabric/fabric-examples/fabric-camel-dosgi

Popular posts from this blog

Apache Karaf

Camel Endpoint DSL

ActiveMQ Pooling