Processing commands that interact with sensors in Java
Now that you have understood how to work with the Paho Java Client, its non-blocking API, and its callbacks, we can develop the Java application that will process the commands that interact with sensors, based on the previously explained requirements.
We can start another Maven project in our favorite IDE and make the same edits to the pom.xml
file that we did in our previous example to use the Paho Java Client with the Bouncy Castle libraries. In addition, we must include the previously coded SecurityHelper
class. The code file for the sample is included in the mqtt_essentials_gaston_hillar_04
folder, in the Java02
folder.
Now, we will create a new class named SensorsManager
that implements the previously analyzed MqttCallback
interface, specifically the org.eclipse.paho.client.mqttv3.MqttCallback
interface. The class will process the messages that the MQTT client receives, provide many methods that will process the commands included...