Andi Egloff's Weblog

Adventures in technology

« The power of JBI,...
| Main | Fuji GUI sneak peek:...
»

http://blogs.sun.com/andi/date/20080521 Wednesday May 21, 2008

Why is OSGi on everyone's tongue
- or why you should take the red pill

In a JBoss blog on "OSGi - The placebo that will rejuvenate this industry (just ask your vendor)" Sacha paints a picture of everyone just following the latest buzz-word and (at least in title) not much substance.

So is that really the end of the story?

Hold on, wouldn't that be a really strange story for Sun which had quite a mixed and turbulent affair with OSGi in the past? And now we (as in Sun) are barrelling ahead with native OSGi support in GlassFish v3 as well as Open ESB with Project Fuji... Doesn't seem to make sense that they'd just change their minds for a cheap thrill of name dropping...

I'll admit it now. before digging into it I was very skeptical of OSGi; not that I didn't like the premise of abolishing classpath hell, but oftentimes enterprise quality features come at a large cost of complexity. Also the worry was if the "API" based services of OSGi would mesh well with the message-based, mediated services architecture we require for our SOA / integration platform with lofty goals and a lot to live up to. Project Fuji is all about looking at every aspect of our platform and making it more approachable and flexible, so if a technology doesn't add enough there is no way I'm going to add it.

Now, I'm completely sold. It turns out the OSGi spec does its core job very well and in a very stable fashion; plus it actually is surprisingly straight forward for our platform to take advantage of without being overly intrusive. In fact to start with it only required one minor enhancement (adding some additional entries in the jar's manifest.mf) to make our existing adapters, containters as well as applications run in OSGi enabled environments.

Also it turns out that the current standard for message based, mediated exchanges - Java Business Integration (JBI) - sits very well on top of OSGi and in fact our experiences so far in Project Fuji indicate that the specs add features to each other that really have the potential to bring out the best in both. We simply made our JBI framework implementation an OSGi bundle which then can listen for bundle deployments it should service..

What we gain from OSGi in Fuji

  • Take control of classpath hell - by being very explicit about what "services" (interfaces) to expose from a jar (bundle) and in turn declaring exactly what external services and their versions we consume from other bundles it creates a very robust way of managing dependencies and easily allows for multiple versions without conflct
  • Sizes to fit your problem. Only installs the containers / adapters needed, no need to add complexity or overhead with parts of the system you don't need
  • Easy to dynamically add features to the platform. We leverage a whiteboard pattern for example to add interceptors within the message routing.
  • Trivial to create a stand-alone distribution that can be zipped up and installed anywhere. The well defined dependencies of your application and the OSGi enabled pieces allow us to easily find and package all the required pieces for a given application with one command/click.
  • Allows us to focus on the real value of the platform and leaves the lower level grunt work of a component model to a very robust solution with multiple implementation choices. The core runtime implementation of Fuji on top of OSGi is currently under 300K!
  • The ability to safely exchange optimized payload representations (such as POJOs) between loosely coupled services becomes a reality
  • More deployment options, easy to run on any OSGi enabled runtime, small size allows flexibility to embed even in platforms wtihout OSGi out of the box
And we're only scratching the surface here, we're planning to leverage more features of OSGi!

Some of what OSGi currently gains with Fuji

  • Mediated model allows for easily adding platform value-add such as auditing, security, routing features ...
  • A message based, very loosely coupled service layer can make for more stable production system with lower maintenance; it also meshes well with other SOA systems.
  • Inherent scalability without explicit coding of a SEDA based architecture; threads are not tied to specific requests, components choose the optimal way to process the messages
  • Interoperability of any component plugged into this layer; standard contract for exchanging messages without prior knowledge of the provider or consumer
  • More choice of adapters and containers, from multiple vendors; combined with interoperability this can allow for best of breed in a unified platform
  • A very productive way of defining routing / message flows between services using common patterns that closely match the problem domain by using the Integration flow language (IFL) - a domain specific language (DSL)

Now also throw in all the capabilities of an application server getting modularized and natively supporting OSGi; as the GlassFish team is doing with GlassFish v3, and Fuji gains even more capabilities it can leverage to add scripting, web container, ejb, comet etc... support; without having to create one huge deployable that you may only use 10% of... (hint: stay tuned for what we're cooking up with GlassFish ESB v3 as well ;) ).

Now with the above said, I don't expect all our users to rush out and learn the deepest ins and outs of OSGi. Just like JBI, I primarily see this as an enabling technology for the platform, only if you want to extend the platform itself would you typically touch it directly. As an example I'd expect users to develop simple scripts or POJOs and for example use Spring DM to consume and provide services; so you inherit the advantages of the platform without necessarily having to explicitly touch the underlying technologies.

Coming back to the original blog I am curious how easy it will be to leverage the OSGi-on-the-side story and "don't use it directly" approach JBoss seems to be talking about so far, I would personally like to see Fuji on top of JBoss with an easy way to natively leverage all it's capabilties in the near future as well :)

Comments:

Some application developers like to know how things work under-the-covers even if its not necessary to build their apps.

Can you walk through a simple example so we can see how msgs move between the JBI components and the OSGi bundles?

thanks
J

Posted by Jason on May 23, 2008 at 08:25 AM CDT #

Excellent summary of your experience. Clearly, OSGi technology is not a silver bullet, but for situations where it is beneficial, it can really help a lot.

Posted by Richard S. Hall on May 23, 2008 at 09:15 PM CDT #

Jason, one thing to realize is that the JBI components (or service containers in more generic terms) are OSGi bundles themselves; as is the application deployed to them.

Also, the service bus (normalized message router or NMR in JBI terms) is installed as a JBI bundle. The API "contract" to interact with the service bus is exposed as an OSGi service, hence any bundle can look it up and send or receive messages from it - it actually doesn't have to have to be a JBI component! So any OSGi bundles can participate on the message-based service layer and provide and consume services on it.

So let's say we route message arriving on an FTP server to a JRuby service. The application jar will have a configuration for FTP and a JRuby script with a "process" method. The JBI framework recognizes this kind of OSGi bundle and deploys to the FTP binding and the JRuby engine.

1. When the FTP binding polls a file, it will use the service bus (NMR) contract it obtained from OSGi to send the message.

2. The service bus routes it to the JRuby engine (which also obtained the service bus contract from OSGi and is advertizing a JRuby service endpoint, listening for invocations)

3. The JRuby engine invokes the user's JRuby script with the message

HTH
Andi

Posted by Andi on June 10, 2008 at 02:16 PM CDT #

Is there a service engine for using Spring DM with Fuji?

I have been looking around the web for some time now and it would appear that the only way to get Spring DM working with JBI is via ServiceMix and ServiceMix's Spring SE requires the entire ServiceMix JBI implementation.

Also, from the API it is pretty clear how one can use the FUJI APIs to put messages onto the NMR but it is anything but obvious how to use the service to listen for/consume messages coming from the NMR.

Any chance we can see some concrete examples?

Thanks,

-James

Posted by James Peltzer on June 13, 2008 at 01:37 PM CDT #

Post a Comment:
  • HTML Syntax: NOT allowed

Valid HTML! Valid CSS!

Andreas Egloff is the Lead Architect for SOA / Business Integration at Sun Microsystems, Inc.
This is a personal weblog, I do not speak for my employer.