Subscribing to topics and understanding notification events in Java

The onSuccess method prints a message indicating that the client has successfully connected with the MQTT server and then calls the mqttAsyncClient.subscribe method with topic_for_led01 as the argument that specifies the topic filter to subscribe to 0 for the argument that specifies the desired QoS level, null for the userContext argument, and another anonymous class that implements the IMqttActionListener interface as the value for the callback argument. As happened with the connect method, the subscribe method requires the callback argument of the org.eclipse.paho.client.mqttv3.IMqttActionListener type. The anonymous class provides implementations for the previously explained ...

Get MQTT Essentials - A Lightweight IoT Protocol now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.