Sending messages via Websphere MQ, a simple Clojure example

Written by fsmunoz on 23 June 2013 Categories: Clojure, Lisp, M2M

I have been exploring different ways to integrate information (in the context of SmarterCities work) with a central repository that can be used to correlate it. The IBM Intelligent Operations Center comes with both Websphere MQ and Webpshere Message Broker, so this is the most obvious integration point I use for testing some ideas.

Since I’ve started using Clojure for some experiences – namely because it’s a good way to use the JVM and the Java libraries while still remaining in Lisp land – I went looking for ways to send messages.

After a while I decided to use the Websphere MQ classes for JMS to produce the example bellow (follow the links to the full gist):

A simple HTTP POST would actually suffice but I wanted to use some kind of messaging mechanism. I explored JMS – which on the surface sounded like the most obvious choice – but after a while I must confess becoming a bit lost on the number of operations, JNDI config files and above all necessary libs needed: it seems that JMS is the “standard Java messaging”, but relies on external providers for some of the work. What this meant was that it was not so “batteries included” as expected, while at the same time being a bit byzantine for my modest needs.

Defining a Message Broker workflow

A MQInput node listens to a specific queue, then passes it out to a FileOutput which appends the message in a file.

The Message Broker Toolkit makes it almost excindingly easy to pick this message and define a workflow; here I simply created a MQInput that listens to a node and passes it up to a File node that saves it to a temp file.

Much more complex routing and transformations are possible: nodes allow for immediate processing of, say, XML, JSON, MIME, which makes it trivial to get the information needed without any code at all.

I will follow this post with my preferred solution for M2M and light-weight messaging as a whole: MQTT, which is really easy to use. I didn’t even imagined how easy before venturing amidst the world of messaging in the context of service buses.

1 Comment on Sending messages via Websphere MQ, a simple Clojure example

1 Comment