in iothub/device/iot-device-client/src/main/java/com/microsoft/azure/sdk/iot/device/transport/IotHubTransport.java [258:320]
public void onMessageSent(Message message, String deviceId, TransportException e)
{
if (message == null)
{
log.warn("onMessageSent called with null message");
return;
}
log.debug("IotHub message was acknowledged. Checking if there is record of sending this message ({})", message);
// remove from in progress queue and add to callback queue
IotHubTransportPacket packet;
synchronized (this.inProgressMessagesLock)
{
packet = inProgressPackets.remove(message.getMessageId());
}
if (packet != null)
{
if (e == null)
{
log.trace("Message was sent by this client, adding it to callbacks queue with OK ({})", message);
packet.setStatus(IotHubStatusCode.OK);
this.addToCallbackQueue(packet);
}
else
{
this.handleMessageException(packet, e);
}
try
{
String correlationId = message.getCorrelationId();
if (!correlationId.isEmpty())
{
CorrelationCallbackContext callbackContext = correlationCallbacks.get(correlationId);
if (callbackContext != null && callbackContext.getCallback() != null)
{
IotHubClientException clientException = null;
if (e != null)
{
clientException = e.toIotHubClientException();
}
callbackContext.getCallback().onRequestAcknowledged(packet.getMessage(), callbackContext.getUserContext(), clientException);
}
}
}
catch (Exception ex)
{
log.warn("Exception thrown while calling the onRequestAcknowledged callback in onMessageSent", ex);
}
}
else
{
// For instance, a message is sent by a multiplexed device client, the client is unregistered, and then the
// client receives the acknowledgement for that sent message. Safe to ignore since the user has opted to stop
// tracking it.
log.trace("A message was acknowledged by IoT hub, but this client has already stopped tracking it ({})", message);
}
}