@Override public IotHubStatusCode sendMessage(com.microsoft.azure.sdk.iot.device.Message message) throws TransportException { AmqpsConvertToProtonReturnValue amqpsConvertToProtonReturnValue = this.convertToProton(message); if (amqpsConvertToProtonReturnValue == null) { // Codes_SRS_AMQPSTRANSPORT_34_076: [The function throws IllegalStateException if none of the device operation object could handle the conversion.] throw new IllegalStateException("No handler found for message conversion!"); } // Codes_SRS_AMQPSTRANSPORT_34_077: [The function shall attempt to send the Proton message to IoTHub using the underlying AMQPS connection.] Integer sendHash = this.sendMessage(amqpsConvertToProtonReturnValue.getMessageImpl(), amqpsConvertToProtonReturnValue.getMessageType(), message.getConnectionDeviceId()); if (sendHash != -1) { // Codes_SRS_AMQPSTRANSPORT_34_078: [If the sent message hash is valid, it shall be added to the in progress map and this function shall return OK.] this.inProgressMessages.put(sendHash, message); return IotHubStatusCode.OK; } else { // Codes_SRS_AMQPSTRANSPORT_34_079: [If the sent message hash is -1, this function shall throw a retriable ProtocolException.] ProtocolException protocolException = new ProtocolException("Send failure"); protocolException.setRetryable(true); throw protocolException; } }
separatorNeeded = appendPropertyIfPresent(stringBuilder, separatorNeeded, TO, message.getTo()); separatorNeeded = appendPropertyIfPresent(stringBuilder, separatorNeeded, OUTPUT_NAME, message.getOutputName()); separatorNeeded = appendPropertyIfPresent(stringBuilder, separatorNeeded, CONNECTION_DEVICE_ID, message.getConnectionDeviceId()); separatorNeeded = appendPropertyIfPresent(stringBuilder, separatorNeeded, CONNECTION_MODULE_ID, message.getConnectionModuleId()); separatorNeeded = appendPropertyIfPresent(stringBuilder, separatorNeeded, CONTENT_ENCODING, message.getContentEncoding());
if (message.getConnectionDeviceId() != null) userProperties.put(MessageProperty.CONNECTION_DEVICE_ID, message.getConnectionDeviceId());