use of org.apache.qpid.proton.amqp.messaging.Section in project azure-iot-sdk-java by Azure.
the class AmqpsTransport method iotHubMessageToProtonMessage.
/**
* Creates a proton message from the IoTHub message.
* @param message the IoTHub input message.
* @return the proton message.
*/
private MessageImpl iotHubMessageToProtonMessage(com.microsoft.azure.sdk.iot.device.Message message) {
logger.LogInfo("Started converting IoT Hub message into AmpqsMessage, method name is %s ", logger.getMethodName());
MessageImpl outgoingMessage = (MessageImpl) Proton.message();
logger.LogInfo("Content of message is %s, method name is %s ", new String(message.getBytes(), Message.DEFAULT_IOTHUB_MESSAGE_CHARSET), logger.getMethodName());
Properties properties = new Properties();
if (message.getMessageId() != null) {
properties.setMessageId(message.getMessageId());
}
outgoingMessage.setProperties(properties);
// Codes_SRS_AMQPSTRANSPORT_15_038: [The function shall add all user properties to the application properties of the Proton message.]
if (message.getProperties().length > 0) {
Map<String, String> userProperties = new HashMap<>(message.getProperties().length);
for (MessageProperty messageProperty : message.getProperties()) {
if (!MessageProperty.RESERVED_PROPERTY_NAMES.contains(messageProperty.getName())) {
userProperties.put(messageProperty.getName(), messageProperty.getValue());
}
}
ApplicationProperties applicationProperties = new ApplicationProperties(userProperties);
outgoingMessage.setApplicationProperties(applicationProperties);
}
Binary binary = new Binary(message.getBytes());
Section section = new Data(binary);
outgoingMessage.setBody(section);
logger.LogInfo("Started converting IoT Hub message into AmpqsMessage, method name is %s ", logger.getMethodName());
return outgoingMessage;
}
Aggregations