Untitled
unknown
plain_text
3 years ago
805 B
6
Indexable
mqttClient.setCallback(new MqttCallback() {
public void messageArrived(String topic, MqttMessage message) throws Exception {
String time = new Timestamp(System.currentTimeMillis()).toString();
System.out.println("\nReceived a Message!" +
"\n\tTime: " + time +
"\n\tTopic: " + topic +
"\n\tMessage: " + new String(message.getPayload()) +
"\n\tQoS: " + message.getQos() + "\n");
latch.countDown(); // unblock main thread
}
public void connectionLost(Throwable cause) {
System.out.println("Connection to Solace broker lost!" + cause.getMessage());
latch.countDown();
}
public void deliveryComplete(IMqttDeliveryToken token) {
}
});
mqttClient.subscribe("T/GettingStarted/pubsub", 0);Editor is loading...