Red Hat JBoss A-MQ and IoT Project
Part 1 - The concepts
What is MQTT?
MQTT is a machine-to-machine (M2M)/"Internet of Things" connectivity protocol. It was designed as an extremely lightweight publish/subscribe messaging transport. It is useful for connections with remote locations where a small code footprint is required and/or network bandwidth is at a premium. 
MQTT is now an open standard through OASIS. The first meeting of the OASIS MQTT Technical Committee was held on 26 March 2013 in Boston as a F2F (Face 2 Face) meeting.  A very good overview on MQTT from Dave Locke is in the references. 
What is Red Hat JBoss A-MQ?
A small footprint, high performance, open source messaging platform based on Apache ActiveMQ.  Under the Red Hat Developer program the JBoss A-MQ Enterprise software is available for developers to try, FOR FREE!
What supporting projects are included in the demonstration?
The demonstration includes code from the Red Hat JBoss Fuse MQTT Client library that Hiram Chirino started. The library supports Blocking, Future and Callback/Continuation Passing Based APIs. The source is located in the references.  I included the library in the project. I also utilized the code from Jason Sherman for the sample Android Application.   In addition I utilized Eric Schabell's JBoss Rock Star template for a quick build of the demonstration. 
The only updates to the activemq.xml file that are required are:
-The transport connector for mqtt. The standard port is 1883.
<transportConnectors> <transportConnector name="openwire" uri="tcp://0.0.0.0:61616"/> <transportConnector name="mqtt" uri="mqtt+nio://0.0.0.0:1883"/> </transportConnectors>
-To enable security we just use the SimpleAuthenticationPlugin.
<plugins> <simpleAuthenticationPlugin> <users> <authenticationUser username="system" password="manager" groups="users,admins"/> <authenticationUser username="user" password="password" groups="users"/> <authenticationUser username="guest" password="password" groups="guests"/> </users> </simpleAuthenticationPlugin> </plugins>
The main code in the Android app is in the MQTTActivity.java file in the org.example.mqtt package. The android app UI is in the main.xml and can be seen in the graphical layout.
Part 2 - The demo
Steps to build and run the demo
- Download the code from github at https://github.com/kpeeples/a-mq-android-mqtt
- Download Red Hat JBoss A-MQ from https://www.jboss.org/products/amq.html and place in the installs directory.
- Download the Android Bundle from http://developer.android.com/sdk/index.html and unzip.
- Download and start JBoss Developer Studio 7 or the Fuse IDE.
- Add the Android Developer Plugins http://rgladwell.github.com/m2e-android/updates/
- Create a Android Virtual Device (AVD) through JBDS in the Android Virtual Device Manager in the Window menu. If the Android Virtual Device Manager does not show on the Window menu then Click on Window > Customize perspective > Command Groups Availability tab. Check the "Android SDK and AVD Manager" option and hit the OK button.
- Import the Android project in JBDS
- Run the init.sh to setup A-MQ
- Start A-MQ in the foreground by executing target/jboss-a-mq-6.0.0.redhat-024/bin/amq
- Right click on AndroidManifest.xml and Run As Android.
- Connect to the broker and make sure to use the IP instead of localhost and use a username/password entered from the activemq.xml
- Enter a destination topic and a test message then click send
- The message will sent to the topic, read from the topic and then placed in the received field.