Talk from the EclipseCon 2013.
Mobile devices like smartphones and tablet computers became an integral part of our modern world and single-board computers like Raspberry Pi are cheaper today than at any time before. Simple and open Machine-to-Machine (M2M) protocols like MQTT enable these devices to communicate in an efficient manner, even in scenarios with unreliable und instable networks. This talk shows how Eclipse Paho - an Eclipse umbrella project for M2M protocols - can be utilized for professional and personal projects to build efficient and scalable solutions for (mobile) devices.
27. Why MQTT?
✓ Simple
✓ Efficient
✓ Publish / Subscribe
✓ Quality of Service Levels
✓ Last Will and Testament
✓ Designed for unreliable networks
28. 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
42. 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
43. 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
44. Code!
public void start() throws Exception {
final String clientId = "eclipsecon_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);
}
45. 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")));
}
50. Credits
✓ Scared Cat Picture by http://www.flickr.com/photos/
dat-pics/
✓ Thanks Vincent Le Moign for the awesome Icon Set
✓ Rest of pictures licensed from different people from
500px.com
✓ MQTT Logo by http://www.mqtt.org
✓ Paho Logo from http://wiki.eclipse.org/Paho/Branding