Easy! Here's my Pi recipe:
1 Raspberry Pi
1 IBM J9 JVM
1 WebSphere Liberty Profile server
1 Really Small Message Broker (RSMB)
1 Eclipse Paho client library
1 Andy Stanford-Clark!
Andy has a very pervasive house with many devices set up to both tweet and publish messages based on events which occur to those devices. Furthermore, some devices can be controlled by sending messages to topics which they are monitoring, such as a pond fountain, an outdoor light and even a heated towel rail! The messaging design used was to bridge from the RSMB on the Pi to the existing message broker Andy has set up to monitor and controll his devices. Any messages sent from or received by either broker will be mirrored by the other via the bridge. This makes the remaining design on the Pi beyond the RSMB easy, as we can consider everything is local, to the RSMB. Neat! The visual and interactive side will be taken care of by a web application on the Liberty Profile app server, which connects to the RSMB via an eclipse open source MQTT client project called Paho.
I already had a Debian install with both the OpenJDK and IBM J9 JVM installed with my Liberty Profile application server, which I used to run the snoop servlet that I wrote about in a previous post, and also for a cool dynamic development demo for the new Liberty Profile I ran at the IBM Impact conference in May 2012. My first step was to install, configure and run the RSMB. It doesn't currently run on the ARM architecture, so I needed to build the source on the Pi and it then just worked out the box, easy. Next I needed to create a broker.cfg file which had info to pointed to Andy's existing broker, such as IP address and port number, and also describe which topics I wanted to bridge. This is simply a list of topics with my intended actions, such as 'in' to listen. That's all I needed to do with the RSMB.
My web application itself is a jsp and servlet based webapp which automatically refreshes itself every 5 seconds to keep the dashboard up to date. It bundles the Paho client library which it uses to connect to the RSMB and subscribe to a number of topics which passes messages of interest to the dashboard. The webapp stores info it requires locally in memory for history graphs such as energy consumption. This data is sent to the Google chart facility (why on earth are Google deprecating this cool graphing function? Maybe someone can fill me in via comments). The application server config just has the one feature included, the jsp-2.2 feature, as that's all we need in this environment! This keeps the application server runtime nimble and fast with a low memory footprint.
So what's next?
I've got a couple of things I want to play with next, I quite fancy connecting the Pi up to my current cost meter at home and to my TV as well and display a channel which shows my energy usage. If you have any ideas of what you'd like to see, let me know :o)
For more info check out:
WebSphere Liberty Profile http://wasdev.net
Raspberry Pi - http://raspberrypi.org
Eclipse Paho - http://git.eclipse.org/c/paho/org.eclipse.paho.mqtt.java.git/
RSMB - https://www.ibm.com/developerworks/mydeveloperworks/groups/service/html/communityview?communityUuid=d5bedadd-e46f-4c97-af89-22d65ffee070
MQTT - http://mqtt.org