Spring Integration demos with MQTT
Java Groovy
Latest commit 9666f12 Apr 30, 2014 @andypiper tweaking gitignore


Using Spring Integration with MQTT

Simple Spring Integration example with MQTT.

Based on the Spring Integration guide. Uses Spring Boot to create a standalone executable jar.

Extends the guide example by:

  • (outbound MQTT) publishing received tweets on an MQTT topic (tweets/spring-integration) on the iot.eclipse.org public test broker, instead of writing to a file. The tweets are published with the retained flag set, QoS 0.
  • (inbound MQTT) subscribing to an MQTT topic (inbound) on the iot.eclipse.org public test broker, and writing messages from there to the file ./si/MQTT_INPUT.


./gradlew build


The Spring Integration app requires that clientId and clientSecret (Twitter app values) are set in the environment, e.g.:

java -DclientId=YourClientId -DclientSecret=YourClientSecret -jar build/libs/mqtt-integration-0.4.0.jar

To obtain the clientId and clientSecret values, create an application on the Twitter Application Management page, and use the API key and API secret values in your environment.

outbound MQTT

To see results, subscribe to the relevant topic, e.g.

mosquitto_sub -h iot.eclipse.org -t "tweets/#" -v

inbound MQTT

To see results, publish to any part of the relevant topic tree, e.g.

mosquitto_pub -h iot.eclipse.org -t "inbound/messages" -m "This is a message"

Then tail the file ./si/MQTT_INPUT - each entry will be prepended with a timestamp and the topic used.