endpoint.publish(subscribe.topicSubscriptions().get(0).topicName(), Buffer.buffer("Hello from the Vert.x MQTT server"), subscribe.topicSubscriptions().get(0).qualityOfService(),
/** * Sends the PUBLISH message to the remote MQTT client * @param topic topic on which the message is published * @param payload message payload * @param qosLevel quality of service level * @param isDup if the message is a duplicate * @param isRetain if the message needs to be retained * @return a reference to this, so the API can be used fluently */ public io.vertx.rxjava.mqtt.MqttEndpoint publish(String topic, io.vertx.rxjava.core.buffer.Buffer payload, MqttQoS qosLevel, boolean isDup, boolean isRetain) { delegate.publish(topic, payload.getDelegate(), qosLevel, isDup, isRetain); return this; }
.collect(Collectors.toList())); endpoint.publish(this.topic, Buffer.buffer(this.message), subscribe.topicSubscriptions().get(0).qualityOfService(), false, false, publishSent -> { context.assertTrue(publishSent.succeeded()); this.async.complete();
.collect(Collectors.toList())); endpoint.publish(this.topic, Buffer.buffer(this.message), subscribe.topicSubscriptions().get(0).qualityOfService(), false, false, publishSent -> { context.assertTrue(publishSent.succeeded()); this.async.complete();
/** * Sends the PUBLISH message to the remote MQTT server * @param topic topic on which the message is published * @param payload message payload * @param qosLevel QoS level * @param isDup if the message is a duplicate * @param isRetain if the message needs to be retained * @param publishSentHandler handler called after PUBLISH packet sent with a packetId * @return current MQTT client instance */ public io.vertx.rxjava.mqtt.MqttEndpoint publish(String topic, io.vertx.rxjava.core.buffer.Buffer payload, MqttQoS qosLevel, boolean isDup, boolean isRetain, Handler<AsyncResult<Integer>> publishSentHandler) { delegate.publish(topic, payload.getDelegate(), qosLevel, isDup, isRetain, publishSentHandler); return this; }
/** * Sends the PUBLISH message to the remote MQTT client * @param topic topic on which the message is published * @param payload message payload * @param qosLevel quality of service level * @param isDup if the message is a duplicate * @param isRetain if the message needs to be retained * @return a reference to this, so the API can be used fluently */ public MqttEndpoint publish(String topic, Buffer payload, MqttQoS qosLevel, boolean isDup, boolean isRetain) { delegate.publish(topic, payload.getDelegate(), qosLevel, isDup, isRetain); return this; }
/** * Sends the PUBLISH message to the remote MQTT client * @param topic topic on which the message is published * @param payload message payload * @param qosLevel quality of service level * @param isDup if the message is a duplicate * @param isRetain if the message needs to be retained * @return a reference to this, so the API can be used fluently */ public io.vertx.rxjava.mqtt.MqttEndpoint publish(String topic, io.vertx.rxjava.core.buffer.Buffer payload, MqttQoS qosLevel, boolean isDup, boolean isRetain) { delegate.publish(topic, payload.getDelegate(), qosLevel, isDup, isRetain); return this; }
/** * Sends the PUBLISH message to the remote MQTT server * @param topic topic on which the message is published * @param payload message payload * @param qosLevel QoS level * @param isDup if the message is a duplicate * @param isRetain if the message needs to be retained * @param publishSentHandler handler called after PUBLISH packet sent with a packetId * @return current MQTT client instance */ public io.vertx.rxjava.mqtt.MqttEndpoint publish(String topic, io.vertx.rxjava.core.buffer.Buffer payload, MqttQoS qosLevel, boolean isDup, boolean isRetain, Handler<AsyncResult<Integer>> publishSentHandler) { delegate.publish(topic, payload.getDelegate(), qosLevel, isDup, isRetain, publishSentHandler); return this; }
/** * Handler for incoming AMQP_PUBLISH message * * @param amqpPublishData object with the AMQP_PUBLISH message */ private void publishHandler(AmqpPublishData amqpPublishData) { AmqpPublishMessage publish = amqpPublishData.amqpPublishMessage(); // defensive ... check that current bridge has information about subscriptions and related granted QoS // see https://github.com/EnMasseProject/subserv/issues/8 // try to get subscribed topic (that could have wildcards) that matches the publish topic String topic = (this.grantedQoSLevels.size() == 0) ? null : TopicMatcher.match(this.grantedQoSLevels.keySet().stream().collect(Collectors.toList()), publish.topic()); if (topic != null) { // MQTT 3.1.1 spec : The QoS of Payload Messages sent in response to a Subscription MUST be // the minimum of the QoS of the originally published message and the maximum QoS granted by the Server MqttQoS qos = (publish.qos().value() < this.grantedQoSLevels.get(topic).value()) ? publish.qos() : this.grantedQoSLevels.get(topic); this.mqttEndpoint.publish(publish.topic(), publish.payload(), qos, publish.isDup(), publish.isRetain()); // the the message identifier assigned to the published message amqpPublishData.setMessageId(this.mqttEndpoint.lastMessageId()); LOG.info("PUBLISH [{}] to MQTT client {}", this.mqttEndpoint.lastMessageId(), this.mqttEndpoint.clientIdentifier()); // for QoS 0, message settled immediately if (qos == MqttQoS.AT_MOST_ONCE) { this.rcvEndpoint.settle(amqpPublishData.messageId()); } } else { LOG.error("Published message : MQTT client {} is not subscribed to {} !!", this.mqttEndpoint.clientIdentifier(), publish.topic()); } }
final String topic = String.format("%s/%s/%s/%s/%s/%s", subscription.getEndpoint(), tenantId, deviceId, subscription.getRequestPart(), commandRequestId, command.getName()); endpoint.publish(topic, command.getPayload(), qos, false, false); metrics.incrementCommandDeliveredToDevice(subscription.getTenant()); LOG.trace("command published to device [tenant-id: {}, device-id: {}, MQTT client-id: {}]",
commandContext.getCurrentSpan().log(items); endpoint.publish(topic, command.getPayload(), subscription.getQos(), false, false, sentHandler -> { if (sentHandler.succeeded()) { if (MqttQoS.AT_LEAST_ONCE.equals(subscription.getQos())) {