/** * Sets handler which will be called each time publish is completed * @param publishCompletionHandler handler called with the packetId * @return current MQTT client instance */ public io.vertx.rxjava.mqtt.MqttClient publishCompletionHandler(Handler<Integer> publishCompletionHandler) { delegate.publishCompletionHandler(publishCompletionHandler); return this; }
/** * Sets handler which will be called each time publish is completed * @param publishCompletionHandler handler called with the packetId * @return current MQTT client instance */ public io.vertx.rxjava.mqtt.MqttClient publishCompletionHandler(Handler<Integer> publishCompletionHandler) { delegate.publishCompletionHandler(publishCompletionHandler); return this; }
private void clientSendThreePublishMessages(MqttQoS mqttQoS, TestContext context) { Async async = context.async(3); MqttClient client = MqttClient.create(vertx); Queue<Integer> expectOrder = new LinkedList<>(); // order we expect to receive acknowledgment for published message expectOrder.add(2); expectOrder.add(1); expectOrder.add(3); client.publishCompletionHandler(h -> { context.assertEquals(h.intValue(), expectOrder.poll()); log.info("[CLIENT] Publish completed for message with id: " + h); async.countDown(); }); client.connect(MqttClientOptions.DEFAULT_PORT, MqttClientOptions.DEFAULT_HOST, c -> { // publish QoS = 1 message three times for (int i = 0; i < 3; i++) client.publish(MQTT_TOPIC, Buffer.buffer(MQTT_MESSAGE.getBytes()), mqttQoS, false, false, h -> log.info("[CLIENT] publishing message id = " + h.result())); }); async.await(); client.disconnect(); }
private void clientSendThreePublishMessages(MqttQoS mqttQoS, TestContext context) { Async async = context.async(3); MqttClient client = MqttClient.create(vertx); Queue<Integer> expectOrder = new LinkedList<>(); // order we expect to receive acknowledgment for published message expectOrder.add(2); expectOrder.add(1); expectOrder.add(3); client.publishCompletionHandler(h -> { context.assertEquals(h.intValue(), expectOrder.poll()); log.info("[CLIENT] Publish completed for message with id: " + h); async.countDown(); }); client.connect(MqttClientOptions.DEFAULT_PORT, MqttClientOptions.DEFAULT_HOST, c -> { // publish QoS = 1 message three times for (int i = 0; i < 3; i++) client.publish(MQTT_TOPIC, Buffer.buffer(MQTT_MESSAGE.getBytes()), mqttQoS, false, false, h -> log.info("[CLIENT] publishing message id = " + h.result())); }); async.await(); client.disconnect(); }
MqttClient client = MqttClient.create(Vertx.vertx()); client.publishCompletionHandler(pubid -> { assertTrue(pubid == messageId); log.info("publishing complete for message id = " + pubid);
MqttClient client = MqttClient.create(Vertx.vertx()); client.publishCompletionHandler(pubid -> { assertTrue(pubid == messageId); log.info("publishing complete for message id = " + pubid);