In this chapter, we will write Java code to control sensors with MQTT messages. We will write code that will be able to run on different popular IoT platforms. We will:
Understand the requirements to control sensors with MQTT
Define the topics and commands to control sensors
Install the Eclipse Paho Java Client
Create a security helper class to establish a TLS secured connection
Configure a TLS secured connection in Java
Work with asynchronous notifications and callbacks in Java
Subscribe to topics and understand notification events in Java
Process commands that interact with sensors in Java
Work with last will and testament in Java
Publish messages with commands to target sensors