Tuesday, November 9, 2010

Mule says no thanks to OSGi.

Ross Mason of MuleSoft posted an article where he argues that OSGi is too complex for end user developer. Although I can sympathize, I do not completely agree. Yes there are areas where OSGi is middleware centric. Yes there are always things that should be simplified. Yes there are pains moving to OSGi.

OSGi is a Dynamic Module System for Java. The key word is Module. Modularity is hard, not OSGi. Properly drawing boundaries between components is hard. Getting communication protocols and APIs right is hard. Unlearning habits of the past is hard.

Dynamic is not something that a regular developer ever learned to deal with properly. For years we have been in a servlet world, where one never really worried about resources/services disappearing or even cared about writing code to account for a multi-threading. I still see code that treats HttpSession as a private HashMap.

Think about all the iterations that enterprise Java went through and all of the technologies involved. CORBA, EJB1, EJB2, RMI, JINI, JNDI, JSP, JDBC, JMS, JCA, JPA, WS-(death)*, and on and on. How many books, articles, man-years of effort and learning went into getting developers to understand that set of technologies? All sorts of stacks and frameworks were built to hide the complexities of that set of technologies. Struts, WebWork, iBatis, Hibernate, Spring (later validated with EJB3/JEE5 and 6), Facelets, Seam, etc. That is a lot of effort from a lot of very smart people to get us to where we are now. It is very easy now to write an app in 3-4 weeks that is useful, pretty and functional. The same would be one to two years of manpower with EJB+JSP+"name the container you hate the most" just seven, six or even five years ago.

With OSGi the situation is very similar to the days of EJB1. Very little information was available in dead-tree format (until recently) and not too many people who you knew were using OSGi. Advice was hard to come by. Surrounding ecosystem was narrowly focused on middleware, embedded devices or Eclipse plugins. The situations is improving dramatically lately. Books are getting published (check out OSGi in Action and Spring DM in Action). OSGi Alliance has started a wiki to spread the jungle knowledge. Many OSS projects are picking up OSGi and provide feedback and information on project specific pages.

OSGi is a great technology, but it is fairly low level technology. It is like coding your whole application persistence logic with JDBC all over again. There are number of OSGi specs that address most of perceived complexities of OSGi: Declarative Services (DS) and Blueprint (Eclipse/SpringDM and Apache Aries) bring DI capabilities to OSGi. Building OSGi bundle metadata becomes simpler by the use of tooling support provided by bnd, bundlor and IDE tooling. Containers like Apache Karaf and Eclipse Virgo are simplifying the use of OSGi with each release.

Having said that, there is one issue with OSGi. Please bear with me while I address it in a roundabout way.

I think it was 2007 or 2008. I was at the SpringExperience/SpringOne conference. There was a lot of talk about data grids, super-duper distributed caching, mass scaling. All that sounded like candy to me. During one of the BOFs I asked Rob Harrop of SpringSource fame - "what is stopping adoption of this technology for use in an everyday project". His answer was very interesting and I wish I wrote it down, but it boiled down to (paraphrasing) :
Developers want to use APIs and tools that they already know. If there are serious limitations on usage of those tools and APIs, developers tend to scream bloody murder and bail.
OSGi is a different programming model from what we have learned to use so far. It has different quirks (TCCL handling is undefined in the spec for example) and not all libraries that we grew up with play nicely in that different programming model. Until all/most of the current cream of the crop libraries work seamlessly, or with very limited, configuration-only changes (no recompile/re-bundling required), there will be a push back on OSGi adoption.

I do not consider myself an OSGi evangelist or a zealot. I really do not think that OSGi is a golden hammer or a nail. OSGi and modularity forces architects and developers to think about overall architecture in much more detail. There are projects that just don't need it. But there are applications that will benefit greatly from OSGi support. Those applications will tend to have a longer lifespans without complete rewrites and will be less complex after 2 years in production than a usual package tangle that is found in other so called "enterprise" applications.

6 comments:

Richard Nicholson said...

+1

Edward said...

Thanks for sharing Dmitry, I'd be interested to get your take on a similar-ish conversation about components going on here:
http://www.osgi.org/blog/2010/07/scala-components-vs-osgi.html

Unknown said...
This comment has been removed by the author.
Unknown said...

Well, I'm still saying no to Mule, but to be fair, I also say no to openESB/glassfish/Fuji and let's go further - Informatica and Microsoft DTS. What I actually say Yes to is an ever-shortening list, and I hope that someday Oracle makes Paremus' offerings free in a way that rewards the Paremus guys (Hi Richard). Oracle's stewardship of Java puts a lot into question. Maybe I should start coding in Ruby.

Charlie mordant said...

And I really liked the way they moderated comments on their post to leave only those which were OSGI-negative.

Mule No thanks, OSGI is the only true way for now, especially for middlewares

Unknown said...

Hello Buddy,



Love it absolutely! So crystalline. No mumbo jumbo. No non-sense. Straight and simple. You guys need a standing ovation for your good work.

Recently, the RAML team decided it was time for an updated server infrastructure. The original site used a web-based Content Management System (CMS) that required a lot of costly server resources. Each client request to the CMS invoked scripts that rendered the pages from outside sources, such as the database and theme;
This led to significant processing time before providing what was, in most cases, a static page. Of course, we ran a caching layer in front of the web server to speed up some requests,


It was cool to see your article pop up in my google search for the process yesterday. Great Guide.
Keep up the good work!


Thanks a heaps,