Scripting and asynchronous messaging

by Dejan Bosanac

One of the lessons we can learn from early success of the Web was making of ideal environment for use of scripts. There were two main components of the Web platform:

  • Web server (Apache), as an infrastructural component that had to be fast and reliable
  • Web application as a collection of scripts (Perl, PHP, Python), providing the content in an easy manner


The Web as we know it today is a much different place; applications talk to each other through variety of web service protocols, we have Ajax and all these new cool toys. But one principle remains the same: we need reliable infrastructure software with easy integration of scripts for fast creation of content and logic.

I've always seen Java as an ideal platform for building infrastructural applications. One of the proofs for this claim is existence of many production-ready asynchronous-messaging solutions on the Java platform. Asynchronous messaging is an important programming concept which is one of the reasons for Java's success in the enterprise environment. JMS specification and many quality implementations of brokers and clients led to wide adoption of messaging paradigm among Java developers.

Recent trend towards bringing asynchronous messaging closer to scripting world is very encouraging (in my opinion) as it will bring completely new programming concepts to script developers and much wider adoption of asynchronous messaging patterns.

What I primarily have in mind here is Stomp (Streaming Text Orientated Messaging Protocol), a lightweight messaging protocol, which makes it easy to implement clients for most of the scripting languages (the most of the mainstream scripting languages already have Stomp clients implemented). Currently only ActiveMQ implements native Stomp support and enables script developers to enjoy all goodness of loosely-coupled asynchronous integration of their applications. Support for virtually any JMS broker is provided through StompConnect project.

One other potential alternative to Stomp is AMQP (Advanced Message Queuing Protocol), the specification that aims to standardize messaging. Intention of AMQP is not to be simple, but to provide standard specification that will allow implementation of brokers and clients in virtually any programming language.

AMQP is young specification and currently you can find it implemented in Qpid (http://cwiki.apache.org/qpid/) project in Apache's incubator. It currently implements brokers in Java and C++ and clients in Java, C++, C#, Python and Ruby. The other open source project that implements AMQP protocol is RabbitMQ, which is written in Erlang and provides clients in Java, JavaScript and native Erlang.

Regardless of the actual protocol and technology being used, I think that asynchronous messaging and scripting provides a lot of potential to developers and I'm sure we will hear a lot of about these two playing together in coming years.

5 Comments

Andrew Kuklewicz
2007-05-04 22:26:43
I agree that regardless of all the other 'cool' advances, messaging remains a staple for developers once they leave the pond of MVC.


A few things: there is another stomp implementation: the Ruby implementation StompServer. Personally, I run Stomp using AMQ, but the option is there.


And for those that want to integrate messaging into their rails apps, I would also recommend the ActiveMessaging plugin which brings the simplicity of rails to messaging (that's the goal anyway). The project has always used stomp as the default protocol (though others are not supported), and a good relationship with the AMQ and ruby stomp developers. For those who have jumped on the RoR bandwagon, but miss JMS/messaging, this is for you.


Thanks for the insightful post,


Andrew Kuklewicz

Jian Wu
2007-05-05 02:15:02
I just want to point out QPid actually is built on top of Apache Mina, if you want to develop Java NIO based asynchronous messaging server or gateway, try Apache Mina.


If you want to develop script based asynchronous messaging server or gateway, then obviously try Python Twisted



Andrew Kuklewicz
2007-05-05 09:22:30
I made a typo in my comment, I meant to say ActiveMessaging now supported other protocols besides stomp (instead of 'not supported'). It has Amazon Simple Queue Service (SQS), and Websphere MQ adapters now as well. Oops.
Parag Shah
2007-05-06 09:59:01
Even though I have not used scripting languages much, one of the things I read about often is that scripting languages do not support the development of "enterprise type" applications.


With support for asynchronous messaging, we will probably move one step closer to developing large, complex, entreprise type applications using scripting languages.


--
Regards
Parag

tundish
2007-07-13 12:38:58
I've written a simple STOMP broker in Python (without using Twisted).


You can find it here:
http://www.thuswise.org/sprinkle/index.html


Have fun!