After quite a wait, Mule 2.0 final is out. Its a pretty big step for us, our users, and our customers. Check out the Whats New page for a rundown of everything. Its a significantly improved release – its much cleaner and easier to use.
Since its Friday and I can’t stare at my IDE any longer, I want to give a quick rundown of the transformation engine which was the primary thing I worked on.
Having implemented two web services frameworks (two more than anyone should ever write), I was getting quite familiar with some of the problems around dealing with XML efficiently. We have many many different representations: DOM, SAX, StAX, bytes[], streams. Applications may work with a variety of these formats as inputs/outputs. Finding the most appropriate match is a difficult one.
A good example of this is where you have one component which can output SAX, DOM, and StAX and another which receives only DOM. When the first component is sending a message, how does it know what to send?
The key was to implement an on demand payload request mechanism. The API is actually similar to what I did with CXF (surprise), but it goes one step further and hooks in the Mule transformation engine. Here’s an example of what the second component would look like.
MuleMessage inputMsg = ...;
Document doc = (Document) inputMsg.getPayload(Document.class);
Quite simple – we’re simply requesting the payload as a Document type. Mule allows you to actually delay any decisions about how to serialize it until getPayload is called. Or you can go down the more traditional route of just choosing some format to send and then have a transformation. i.e. send a SAX stream and convert it to a Document on demand.
As an added benefit, transformations are now automatic – no more manually specifying transformers unless you want to. Mule will use its internal registry of transformers to determine how to best match two components together.
And this concludes our adventure in the world of messaging! If you read this blog entry, you’re probably either sick or are a competitor