Mqtt Notifier is a simple windows application that subscribes to a topic on a MQTT broker and notifies incoming messages via windows notifications.
Download and install the latest JRE 8
(Java Runtime Environment) version.
-
Download the jar executable (
MqttNotifier.jar
) and the sample configuration file and (sample.settings.json
) of the latest version -
Place them in the same directory anywhere on your machine
-
(Optional) Create a shortcut to
MqttNotifier.jar
and move it to%APPDATA%\Microsoft\Windows\Start Menu\Programs\Startup
to haveMqtt Notifier
run on boot
When the application starts up, it will search for a settings.json
file in the same directory. So, in order to use the application, rename sample.settings.json
tosettings.json
and insert the following parameters:
Parameter | Description | Example |
---|---|---|
broker |
String value needed to connect to the MQTT broker [ protocol://ip:port ] | tcp://hostname:1883 |
topic |
Topic name to which the application must subscribe | topicName |
Parameter | Description | Default value |
---|---|---|
clientId |
MQTT client id for the application | MqttNotifier |
appName |
The text displayed as tooltip in the system tray and as title in any INFO or ERROR message | Mqtt Notifier |
notificationTitle |
The notification title of any incoming message from the subscribed topic | New Message |
notificationMessage |
The message notification of any incoming message from the subscribed topic | The received message's payload as string value |
Example:
{
"topic": "doorbell",
"broker": "tcp://my-broker:1883",
"clientId": "DoorbellNotifier",
"appName": "Doorbell Notifier",
"notificationTitle": "DOORBELL!",
"notificationMessage": "dlin dlon"
}
If this application is too generic for your purpose, you can just do some little changes to the source code and then build it.
For example:
-
In case of simple changes, you can modify the behaviour of the
messaggeReceived
method in theMqttNotifier
class -
If your project gets too complex according to the observer pattern, you can create another class that implements the
MqttNotification
interfacepublic class MyClass implements MqttNotification { .... @Override public void messageReceived(String topic, MqttMessage message) { // What you want do when a new message is received } }
and connect it to
MqttSubClient
through theattach()
methodMyClass myClass = new MyClass(); mqttSubClient.attach(myClass);
        In this way your method will be called anytime there is a new messagge.
In future releases I would like to:
-
make it multi-platform
-
add a feature to subscribe to multiple topics (configurable through the configuration file)
-
enable login to broker with username and password
-
Eclipse Paho Java Client - MQTT client library
-
Moshi - JSON library
-
Maven - Dependency Management
This project is released under the MIT License