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())) {
private void setResponsePayload(final HttpServerResponse response, final CommandContext commandContext, final Span currentSpan) { if (commandContext == null) { response.setStatusCode(HttpURLConnection.HTTP_ACCEPTED); } else { final Command command = commandContext.getCommand(); response.putHeader(Constants.HEADER_COMMAND, command.getName()); currentSpan.setTag(Constants.HEADER_COMMAND, command.getName()); LOG.trace("adding command [name: {}, request-id: {}] to response for device [tenant-id: {}, device-id: {}]", command.getName(), command.getRequestId(), command.getTenant(), command.getDeviceId()); if (!command.isOneWay()) { response.putHeader(Constants.HEADER_COMMAND_REQUEST_ID, command.getRequestId()); currentSpan.setTag(Constants.HEADER_COMMAND_REQUEST_ID, command.getRequestId()); } response.setStatusCode(HttpURLConnection.HTTP_OK); HttpUtils.setResponseBody(response, command.getPayload(), command.getContentType()); } }
private void setResponsePayload(final HttpServerResponse response, final CommandContext commandContext, final Span currentSpan) { if (commandContext == null) { response.setStatusCode(HttpURLConnection.HTTP_ACCEPTED); } else { final Command command = commandContext.getCommand(); response.putHeader(Constants.HEADER_COMMAND, command.getName()); currentSpan.setTag(Constants.HEADER_COMMAND, command.getName()); LOG.trace("adding command [name: {}, request-id: {}] to response for device [tenant-id: {}, device-id: {}]", command.getName(), command.getRequestId(), command.getTenant(), command.getDeviceId()); if (!command.isOneWay()) { response.putHeader(Constants.HEADER_COMMAND_REQUEST_ID, command.getRequestId()); currentSpan.setTag(Constants.HEADER_COMMAND_REQUEST_ID, command.getRequestId()); } response.setStatusCode(HttpURLConnection.HTTP_OK); HttpUtils.setResponseBody(response, command.getPayload(), command.getContentType()); } }