I gave this talk at Eclipse Democamp Munich and Stuttgart. This presentation explains the benefits of MQTT, why HTTP isn't enough for the Internet of Things and Machine-to-Machine communication. Last but not least it shows how to use the Eclipse Paho Java library for efficient
14. Why MQTT?
✓ Simple
✓ Efficient
✓ Publish / Subscribe
✓ Quality of Service Levels
✓ Last Will and Testament
✓ Designed for unreliable networks
15. Why MQTT?
✓ Simple
✓ Efficient
✓ Publish / Subscribe
✓ Quality of Service Levels
✓ Last Will and Testament
✓ Designed for unreliable networks
K
Wireless? Yep, then it probably is unreliable
77. What is Paho?
✓ Scalable Open Source Implementations of M2M
standard protocols
✓ Focus on MQTT
✓ Implementations in Java, Javascript, Lua,
C, C++ and Python
✓ Eclipse Incubator
78. What is Paho?
K
Read: What is Paho at the moment
✓ Scalable Open Source Implementations of M2M
standard protocols
✓ Focus on MQTT
✓ Implementations in Java, Javascript, Lua,
C, C++ and Python
✓ Eclipse Incubator
80. Paho - Java
contribution of IBM
announced at
EclipseCon Europe
11/2011
first version
in GIT
03/2012
Release
v0.1
11/2012
Release
v0.2
04/2013
Release
v0.4.0
08/2013
81. Code!
public void start() throws Exception {
final String clientId = "democamp_sub";
final MqttClient mqttClient = new MqttClient(BROKER_URL,
clientId, new MemoryPersistence());
mqttClient.setCallback(new SubscribeCallback(mqttClient));
mqttClient.connect();
mqttClient.subscribe(TOPIC_SUBSCRIPTION,
QUALITY_OF_SERVICE_LEVEL);
}
82. Moar Code!
public class SubscribeCallback implements MqttCallback {
@Override
public void connectionLost(Throwable cause) {}
@Override
public void deliveryComplete(MqttDeliveryToken token) {}
@Override
public void messageArrived(MqttTopic topic,
MqttMessage message)
throws Exception {
System.out.println(
"Message arrived. Topic: "
topic.getName() +
", QoS: " +
message.getQos() +
", message: " +
new String(message.getPayload(),Charset.forName("UTF-8")));
}
87. Credits
✓ Pictures licensed from different people from
500px.com and depositphotos.com
✓ MQTT Logo by http://www.mqtt.org
✓ Paho Logo from http://wiki.eclipse.org/Paho/Branding