
42 Building Smarter Planet Solutions with MQTT and IBM WebSphere MQ Telemetry
}
Subscribe.java: This class creates the subscription and waits for matching publications.
Refer to Example 2-10. The handling of the actual message is delegated to the Callback
class, which is defined in Callback.java. Subscribe.java uses an asynchronous
programming model, which means it does not need to wait for a message to arrive and
block the execution of the program.
Example 2-10 Subscribe.java
package org.mqtt.redbooks.ch2;
import java.util.Scanner;
import com.ibm.micro.client.mqttv3.*;
public class Subscribe {
public static void main(String[] args) {
try {
//a. ...