System.out.println("Just received message on [" + message.topicName() + "] payload [" + message.payload() + "] with QoS [" + message.qosLevel() + "]"); if (message.qosLevel() == MqttQoS.AT_LEAST_ONCE) { endpoint.publishAcknowledge(message.messageId()); } else if (message.qosLevel() == MqttQoS.EXACTLY_ONCE) { endpoint.publishReceived(message.messageId());
final int mqttPacketId = publish.messageId(); LOG.info("PUBLISH [{}] from MQTT client {}", mqttPacketId, this.mqttEndpoint.clientIdentifier()); if (!this.pubEndpoint.isPublisher(publish.topicName())) { ProtonSender senderQoS01 = this.connection.createSender(publish.topicName()); ProtonSender senderQoS2 = this.connection.createSender(publish.topicName()); this.pubEndpoint.addPublisher(publish.topicName(), new AmqpPublisher(senderQoS01, senderQoS2)); publish.qosLevel(), publish.isDup(), publish.isRetain(), publish.topicName(), publish.payload()); if (delivery != null) { if (publish.qosLevel() == MqttQoS.AT_LEAST_ONCE) { this.mqttEndpoint.publishAcknowledge(mqttPacketId); LOG.info("PUBACK [{}] to MQTT client {}", mqttPacketId, this.mqttEndpoint.clientIdentifier());
/** * Used for calling the publish handler when the remote MQTT client publishes a message * * @param msg published message */ void handlePublish(io.vertx.mqtt.messages.MqttPublishMessage msg) { synchronized (this.conn) { if (this.publishHandler != null) { this.publishHandler.handle(msg); } if (this.isPublishAutoAck) { switch (msg.qosLevel()) { case AT_LEAST_ONCE: this.publishAcknowledge(msg.messageId()); break; case EXACTLY_ONCE: this.publishReceived(msg.messageId()); break; } } } }
final String reqId = addressPath[CommandConstants.TOPIC_POSITION_RESPONSE_REQ_ID]; final CommandResponse commandResponse = CommandResponse.from( reqId, targetAddress.getResourceId(), ctx.message().payload(), ctx.contentType(), status); metrics.incrementCommandResponseDeliveredToApplication(targetAddress.getTenantId()); if (ctx.deviceEndpoint().isConnected() && ctx.message().qosLevel() == MqttQoS.AT_LEAST_ONCE) { ctx.deviceEndpoint().publishAcknowledge(ctx.message().messageId());
void handlePublishedMessage(final MqttContext context) { final MqttQoS qos = context.message().qosLevel(); final Span span = tracer.buildSpan("PUBLISH") .ignoreActiveSpan() .withTag(Tags.SPAN_KIND.getKey(), Tags.SPAN_KIND_SERVER) .withTag(Tags.MESSAGE_BUS_DESTINATION.getKey(), context.message().topicName()) .withTag(TracingHelper.TAG_QOS.getKey(), qos.toString()) .withTag(Tags.COMPONENT.getKey(), getTypeName())
ResourceIdentifier.from(endpointName, tenant, deviceId), sender.isRegistrationAssertionRequired(), ctx.message().topicName(), ctx.contentType(), payload, customizeDownstreamMessage(downstreamMessage, ctx); if (ctx.message().qosLevel() == MqttQoS.AT_LEAST_ONCE) { return sender.sendAndWaitForOutcome(downstreamMessage, currentSpan.context()); } else { ctx.message().topicName(), ctx.message().qosLevel(), tenant, deviceId); if (ctx.deviceEndpoint().isConnected() && ctx.message().qosLevel() == MqttQoS.AT_LEAST_ONCE) { currentSpan.log("sending PUBACK"); ctx.deviceEndpoint().publishAcknowledge(ctx.message().messageId());
/** * @return Quality of service level */ public MqttQoS qosLevel() { if (cached_1 != null) { return cached_1; } MqttQoS ret = delegate.qosLevel(); cached_1 = ret; return ret; }
/** * @return Topic on which the message was published */ public String topicName() { if (cached_4 != null) { return cached_4; } String ret = delegate.topicName(); cached_4 = ret; return ret; }
/** * Measure the size of the payload for using in the metrics system. * <p> * This implementation simply counts the bytes of the MQTT payload buffer and ignores all other attributes of the * message. * * @param message The message to measure the payload size. May be {@code null}. * @return The number of bytes of the payload or zero if any input is {@code null}. */ protected long messagePayloadSize(final MqttPublishMessage message) { if (message == null || message.payload() == null) { return 0L; } return message.payload().length(); }
/** * @return Message identifier */ public int messageId() { if (cached_0 != null) { return cached_0; } int ret = delegate.messageId(); cached_0 = ret; return ret; }
/** * @return If the message needs to be retained */ public boolean isRetain() { if (cached_3 != null) { return cached_3; } boolean ret = delegate.isRetain(); cached_3 = ret; return ret; }
/** * @return If the message is a duplicate */ public boolean isDup() { if (cached_2 != null) { return cached_2; } boolean ret = delegate.isDup(); cached_2 = ret; return ret; }
ByteBuf newBuf = VertxHandler.safeBuffer(publish.payload(), chctx.alloc()); MqttPublishMessage mqttPublishMessage = MqttPublishMessage.create( publish.variableHeader().messageId(), publish.fixedHeader().qosLevel(),
/** * Used for calling the publish handler when the remote MQTT client publishes a message * * @param msg published message */ void handlePublish(io.vertx.mqtt.messages.MqttPublishMessage msg) { synchronized (this.conn) { if (this.publishHandler != null) { this.publishHandler.handle(msg); } if (this.isPublishAutoAck) { switch (msg.qosLevel()) { case AT_LEAST_ONCE: this.publishAcknowledge(msg.messageId()); break; case EXACTLY_ONCE: this.publishReceived(msg.messageId()); break; } } } }
final String reqId = addressPath[CommandConstants.TOPIC_POSITION_RESPONSE_REQ_ID]; final CommandResponse commandResponse = CommandResponse.from( reqId, targetAddress.getResourceId(), ctx.message().payload(), ctx.contentType(), status); metrics.incrementCommandResponseDeliveredToApplication(targetAddress.getTenantId()); if (ctx.deviceEndpoint().isConnected() && ctx.message().qosLevel() == MqttQoS.AT_LEAST_ONCE) { ctx.deviceEndpoint().publishAcknowledge(ctx.message().messageId());
void handlePublishedMessage(final MqttContext context) { final MqttQoS qos = context.message().qosLevel(); final Span span = tracer.buildSpan("PUBLISH") .ignoreActiveSpan() .withTag(Tags.SPAN_KIND.getKey(), Tags.SPAN_KIND_SERVER) .withTag(Tags.MESSAGE_BUS_DESTINATION.getKey(), context.message().topicName()) .withTag(TracingHelper.TAG_QOS.getKey(), qos.toString()) .withTag(Tags.COMPONENT.getKey(), getTypeName())
/** * @return Quality of service level */ public MqttQoS qosLevel() { if (cached_1 != null) { return cached_1; } MqttQoS ret = delegate.qosLevel(); cached_1 = ret; return ret; }
/** * @return Topic on which the message was published */ public String topicName() { if (cached_4 != null) { return cached_4; } String ret = delegate.topicName(); cached_4 = ret; return ret; }