Skip to content
Publish-Subscribe Example Clients for Eclipse Paho
Branch: master
Clone or download
Pull request Compare This branch is 2 commits ahead of dobermai:master.
Latest commit 63e10f8 Oct 22, 2014
Type Name Latest commit message Commit time
Failed to load latest commit information.
src/main/java/de/dcsquare/paho/client added paho maven repo and updated to paho 0.4.0 Mar 8, 2014
.gitignore added will message + improved code Aug 1, 2012
README.adoc Created Readme Oct 22, 2014
pom.xml added paho maven repo and updated to paho 0.4.0 Mar 8, 2014


MQTT Publish and Subscribe Examples with Eclipse Paho

This repository contains two MQTT clients, that demonstrate the publish/subscribe pattern and the usage of topics. Additionally Last Will and Testament (LWT), a feature of MQTT to detect an ungracefully disconnected client is implemented examplarily.

Publisher / Sensor Client

The publishes simulates two sensors: temperature and brightness. Each of the sensors has their own topic on which they are constantly publishing random values. On connect the client sends a LWT topic and message to the MQTT broker (in this case HiveMQ on the public MQTT Dashboard). If the client is disconnected ungracefully, the broker will send out the last will message for the client to let other clients know.

Subscriber / Control Center

The second client subscribes to all the topics from the sensor client by using a multi-level wildcard. It will print out every message that arrives on the command line. An additional message will be display, if the LWT message is received. In order to test this behavior it is necessary to exit the sensor client without disconnecting, for example by killing it with Ctrl+C.

You can’t perform that action at this time.