Moxie at 40,000 feet
My intent with this post was to discuss a transport protocol for Moxie, but it’s really not possible to discuss the transport without a notion of the system as a whole. Herewith, a high-level view of how I currently envision the Moxie system.
Moxie Overview
Moxie is (will be) an open, asynchronous, XML messaging system and nothing more. Applications will publish messages to a Moxie server and other applications will retrieve and process those messages. These receiving applications may publish a response back to that same Moxie server or to another Moxie server. The original application — or some other application — will retrieve these “responses” and process them in turn. Nothing terribly new here, except that many of you are probably thinking of a queue-based message oriented middleware (MOM) system, ala MQ-Series — I mean, WebSphere MQ, but I’m not. Instead, Moxie will implement a MOM system using the Tuple Spaces architecture. Even this is not new. Apparently RogueWave tried to do this a few years back with their Ruple product, but for some reason abandoned the effort. I have zero familiarity with Ruple, but it sounds a lot like what I have in mind. I hope its failure is not a reflection on the concept.
Back to Transports
Since the design of Moxie is fluid, I can’t lay it out for you as a fait accomplis. We’ll have to tackle it bit by bit, till a formal specification comes out at the end. For this post we’ll cover the transport. That is, moving messages from point A to point B.
The SOAP specification is transport neutral, and that’s a good thing. In other words, a SOAP system can use any transport to get a SOAP message from here to there. But let’s not kid ourselves, the world has translated “transport neutral” as “HTTP.” Sure, it works just as well over, say, Tibco Rendezvous, and there may even be some deployments that don’t use HTTP, but the technology is called web services for a reason.
I’m siding with the REST camp on this one. HTTP is not a generic transport, it’s an application protocol. And if you don’t abide by the semantics of that protocol, well, then you’re just tunneling. Of course, there was a good reason for using HTTP in the first place; it’s ubiquitous. But web services, by layering on all of the complexity of the WS-* stack, has rendered that point moot, and the REST architecture really owns this argument.
If not HTTP, then what? Well, it seems to me that Moxie needs an entirely new transport. Now calm down. I know the world doesn’t need a new transport, and its not very likely that the security guys are going to let it through the firewall, but bear with me, I think I have that covered.
It’s been said that if the Web was invented today it would fail because the security admins wouldn’t let HTTP through the firewall. I’m not sure I believe that. I think there’s a reason HTTP is allowed through (the first layer, anyway); it’s safe. HTTP is connectionless and stateless (though state has been grafted on), it has a few simple methods: GET, POST, etc., that are well understood, largely idempotent, and sent as clear text. In other words, barring bugs in the httpd implementation and poorly written web applications, there’s not much an attacker can do at the protocol level.
The Moxie transport protocol (the acronym MTP is already taken, so I’ll call it MXTP from here on) will emulate the connectionless and stateless nature of HTTP, but will take the protocol one step further. Recall from the Loose Fish post how it was noted that the WS specifications are simply moving existing opaque and/or proprietary transport protocols off the wire and into the message. Well, that’s what we’ll be doing here. The transport itself will be nothing more than a transient socket connection to the server. If the connection is a write, the server will accept the XML message (if it wants to), place an XML formatted response code on the wire, and disconnect. As Moxie is asynchronus, the server will not return any “meaningful” response. For reads, the server will accept an XPath/XQuery expression, and return a status code and all matching messages. I do worry about being pinged to death with reads, and there’s a possibility of having reads use a slightly different, persistent transport, but that has headaches too so it probably won’t happen. The message itself (to be discussed in future posts) will contain all the necessary header and body information. But response codes have to be thought about now.
MXTP Response Codes
Just as HTTP has methods: GET, POST, PUT, and so on, Tuple Spaces have operations. In its purest form these are: out (write), rd (read), in (take), and eval (start a process). I’m pretty sure I won’t be needing an “eval” operation, but am also pretty sure I’ll want something like a “notify.” Given this, lets see what JavaSpaces has to offer in terms of operations: write, read, take, notify. That looks good. I’m sure there’s a lot to be learned from looking at the HTTP status codes as well.
While it’s not possible at this stage to enumerate all possible response codes, let’s imagine a few so that we can get the XML format right. At the very least there should be an error number and an error message. Like HTTP we’ll glom related messages together in groups of 100.
Success messages first. I think it’s safe to say that we’ll need an “OK” response, lets take a crack at it.
<response> <code>200</code> <message lang="en">Message received</message> </response>
That looks good. For reads and takes we’ll need a “no match” response — which is not an error.
<response> <code>201</code> <message lang="en">No messages matched your request</message> </response>
We may or may not need redirection responses, depending on how URIs are exposed, but we’ll definitely need some error messages though.
<response> <code>400</code> <message lang="en">Message not understood</message> </response>
<response> <code>403</code> <message lang="en">Client not authorized</message> </response>
There’ll be a lot more status codes to come, especially error codes, which I’ll track on Moxie’s living design document. Right now, I just wanted to set some guidelines and try out an XML response format.
Also, from here on in, I’ll be building a reference implementation along with the design. This might take a while as I also plan to use it as a means of learning Ruby. I did order the Ruby book, however, and expect it to arrive tomorrow or the next day. I also need to get Subversion installed and figure out if Ruby has anything comparable to JUnit, etc., etc.
More to come
Updated for formatting
