Building organic software

I’ve been thinking a lot recently about how I can build “organic software” that permits services to transparently join the network and leave again. I want to know when a service joins the network and for it to advertise itself. I want to know when a service leaves the network so its consumers can gracefully adapt. I want a service to browse the network for the services it requires. I don’t want worry about configuration.

This is not new. If I cast my memory back to the big days of JavaOne I remember Jini (now Apache River) being the “big thing”.

Yesterday I started looking at Multicast DNS (and Zeroconf), which is used by Apple’s Bonjour. Once again the Node community has not disappointed, I quickly discovered node_mdns.

I decided to do a quick spike around MQTT, which I have also been looking at. Again, the Node community delivers with MQTT.js.

I have a service that provides an MQTT broker. When the broker is ready it advertises itself on the network.

My client browses the network for an MQTT broker, when it finds one it connects to the broker and starts publishing messages. If the broker leaves the network it stops publishing. When the broker rejoins the network, it is again discovered, and the client resumes publishing again.

Take a look at my Gist.

Although my exploration has been limited I have found it to be simple and robust. As we shift our mindset from the monolithic deployment of software to one where we build, deploy, and scale processes independently I feel this offers some really interesting and exciting possibilities. This is especially true as we look more and more at how we bridge in to the physical world to build real time experiences that consume large amounts of data and tap in to sensor networks. The end solutions are broad, it can be digital marketing, gaming, home automation (or automation anything). I came across Pachube the other day, which folds in to this and opens the door to some really interesting possibilities.



I’ve spent some time recently looking at AMQP. I’ve been using it with RabbitMQ and Node. The de facto library for Node is node-amqp, which is powerful, but I have found it to be too low-level for my every day needs of pub/sub.

I wanted a more succinct syntax for publish and subscribe so I created node-messaging.

Below are some code snippets, for complete examples and further documentation jump over to node-messaging.


messaging.createMessenger( url, function( messenger ) {
    messenger.openForPublish( exchangeName, exchangeOptions, function() {
        messenger.publish( exchangeName, routingKey, { body: "hello world" }, messageOptions );


messaging.createMessenger( url, function( messenger ) {
    messenger.openAndSubscribe( exchangeName, exchangeOptions, queueName, queueOptions, bindingKey, subscribeOptions, function( message ) {
        console.log( "Received message '%s'", message.body );