/** * Convert Proton message to IoTHubMessage if the message type is telemetry * * @param amqpsMessage The Proton message to convert * @param deviceClientConfig The device client configuration * @return the converted message */ @Override protected AmqpsConvertFromProtonReturnValue convertFromProton(AmqpsMessage amqpsMessage, DeviceClientConfig deviceClientConfig) throws TransportException { if (((amqpsMessage.getAmqpsMessageType() == null) || (amqpsMessage.getAmqpsMessageType() == MessageType.DEVICE_TELEMETRY)) && (this.deviceClientConfig.getDeviceId().equals(deviceClientConfig.getDeviceId()))) { // Codes_SRS_AMQPSDEVICETELEMETRY_12_009: [The function shall create a new IoTHubMessage using the Proton message body.] // Codes_SRS_AMQPSDEVICETELEMETRY_12_010: [**The function shall copy the correlationId, messageId, To and userId properties to the IotHubMessage properties.] // Codes_SRS_AMQPSDEVICETELEMETRY_12_011: [The function shall copy the Proton application properties to IoTHubMessage properties excluding the reserved property names.] Message message = protonMessageToIoTHubMessage(amqpsMessage); MessageCallback messageCallback = deviceClientConfig.getDeviceTelemetryMessageCallback(message.getInputName()); Object messageContext = deviceClientConfig.getDeviceTelemetryMessageContext(message.getInputName()); // Codes_SRS_AMQPSDEVICETELEMETRY_12_012: [The function shall create a new AmqpsConvertFromProtonReturnValue object and fill it with the converted message and the user callback and user context values from the deviceClientConfig.] // Codes_SRS_AMQPSDEVICETELEMETRY_12_013: [The function shall return with the new AmqpsConvertFromProtonReturnValue object.] return new AmqpsConvertFromProtonReturnValue(message, messageCallback, messageContext); } else { // Codes_SRS_AMQPSDEVICETELEMETRY_12_008: [The function shall return null if the Proton message type is not null or DEVICE_TELEMETRY.] return null; } }
transportMessage.setMessageCallbackContext(this.config.getDeviceTelemetryMessageContext(transportMessage.getInputName())); break; case UNKNOWN:
transportMessage.setMessageCallbackContext(this.config.getDeviceTelemetryMessageContext(message.getInputName()));