Skip to content

Commit

Permalink
Rename OutgoingMessage to TelemetryMessage.
Browse files Browse the repository at this point in the history
  • Loading branch information
David R. Williamson committed Oct 18, 2022
1 parent fbc284b commit a776535
Show file tree
Hide file tree
Showing 42 changed files with 193 additions and 186 deletions.
12 changes: 6 additions & 6 deletions SDK v2 migration guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,17 @@ but users are still encouraged to migrate to version 2 when they have the chance
| Version 1 API | Equivalent version 2 API |
|:---|:---|
| `DeviceClient` | `IotHubDeviceClient` |
| `DeviceClient.SendEventAsync(...)` | `IotHubDeviceClient.SendTelemetryAsync(...)` |
| `DeviceClient.SendEventBatchAsync(...)` | `IotHubDeviceClient.SendTelemetryBatchAsync(...)` |
| `DeviceClient.SendTelemetryAsync(...)` | `IotHubDeviceClient.SendTelemetryAsync(...)` |
| `DeviceClient.SendTelemetryBatchAsync(...)` | `IotHubDeviceClient.SendTelemetryBatchAsync(...)` |
| `DeviceClient.SetConnectionStatusChangesHandler(...)` | `DeviceClient.ConnectionStatusChangeCallback` |
| `DeviceClient.SetReceiveMessageHandlerAsync(...)` | `DeviceClient.SetIncomingMessageCallbackAsync(...)` |
| `MessageResponse` | `MessageAcknowledgement` |
| `Message` | `IncomingMessage`, `OutgoingMessage` |
| `Message` | `TelemetryMessage`, `IncomingMessage` |
| `DeviceClient.SetRetryPolicy(...)` | `IotHubClientOptions.RetryPolicy` |
| `ExponentialBackOff` | `ExponentialBackOffRetryPolicy` |
| `Message.CreationTimeUtc` | `OutgoingMessage.CreatedOnUtc`, `IncomingMessage.CreatedOnUtc` |
| `Message.EnqueuedTimeUtc` | `OutgoingMessage.EnqueuedtimeUtc`, `IncomingMessage.EnqueuedTimeUtc` |
| `Message.ExpiryTimeUtc` | `OutgoingMessage.ExpiresOnUtc`, `IncomingMessage.ExpiresOnUtc` |
| `Message.CreationTimeUtc` | `TelemetryMessage.CreatedOnUtc`, `IncomingMessage.CreatedOnUtc` |
| `Message.EnqueuedTimeUtc` | `TelemetryMessage.EnqueuedtimeUtc`, `IncomingMessage.EnqueuedTimeUtc` |
| `Message.ExpiryTimeUtc` | `TelemetryMessage.ExpiresOnUtc`, `IncomingMessage.ExpiresOnUtc` |

#### Other notable breaking changes

Expand Down
6 changes: 3 additions & 3 deletions e2e/test/helpers/templates/FaultInjection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ public static class FaultInjection

public static readonly TimeSpan RecoveryTime = TimeSpan.FromMinutes(5);

public static OutgoingMessage ComposeErrorInjectionProperties(
public static TelemetryMessage ComposeErrorInjectionProperties(
string faultType,
string reason,
TimeSpan faultDelay,
TimeSpan faultDuration)
{
return new OutgoingMessage(Guid.NewGuid().ToString())
return new TelemetryMessage(Guid.NewGuid().ToString())
{
Properties =
{
Expand Down Expand Up @@ -70,7 +70,7 @@ public static async Task ActivateFaultInjectionAsync(
try
{
using var cts = new CancellationTokenSource(LatencyTimeBuffer);
OutgoingMessage faultInjectionMessage = ComposeErrorInjectionProperties(
TelemetryMessage faultInjectionMessage = ComposeErrorInjectionProperties(
faultType,
reason,
faultDelay,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public static async Task TestFaultInjectionPoolAmqpAsync(
// Inject the fault into device 0
logger.Trace($"{nameof(FaultInjectionPoolingOverAmqp)}: {testDevices.First().Id} Requesting fault injection type={faultType} reason={reason}, delay={faultDelay}, duration={faultDuration}");
faultInjectionDuration.Start();
OutgoingMessage faultInjectionMessage = FaultInjection.ComposeErrorInjectionProperties(faultType, reason, faultDelay, faultDuration);
TelemetryMessage faultInjectionMessage = FaultInjection.ComposeErrorInjectionProperties(faultType, reason, faultDelay, faultDuration);
await deviceClients.First().SendTelemetryAsync(faultInjectionMessage).ConfigureAwait(false);

logger.Trace($"{nameof(FaultInjection)}: Waiting for fault injection to be active: {faultDelay} seconds.");
Expand Down
16 changes: 8 additions & 8 deletions e2e/test/iothub/DeviceTokenRefreshE2ETests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@ public async Task IotHubDeviceClient_TokenConnectionDoubleRelease_Ok()
Logger.Trace($"{deviceId}: DeviceClient OpenAsync.");
await deviceClient.OpenAsync().ConfigureAwait(false);

Logger.Trace($"{deviceId}: DeviceClient SendEventAsync.");
var testMessage = new OutgoingMessage("TestMessage");
Logger.Trace($"{deviceId}: DeviceClient SendTelemetryAsync.");
var testMessage = new TelemetryMessage("TestMessage");
await deviceClient.SendTelemetryAsync(testMessage).ConfigureAwait(false);

Logger.Trace($"{deviceId}: DeviceClient CloseAsync.");
Expand Down Expand Up @@ -160,9 +160,9 @@ void ConnectionStatusChangeHandler(ConnectionStatusInfo connectionStatusInfo)

deviceClient.ConnectionStatusChangeCallback = ConnectionStatusChangeHandler;

var message = new OutgoingMessage("Hello");
var message = new TelemetryMessage("Hello");

Logger.Trace($"[{testDevice.Id}]: SendEventAsync (1)");
Logger.Trace($"[{testDevice.Id}]: SendTelemetryAsync (1)");
var timeout = TimeSpan.FromSeconds(sasTokenTimeToLive.TotalSeconds * 2);
using var cts1 = new CancellationTokenSource(timeout);
await deviceClient.OpenAsync().ConfigureAwait(false);
Expand All @@ -177,7 +177,7 @@ void ConnectionStatusChangeHandler(ConnectionStatusInfo connectionStatusInfo)
await deviceDisconnected.WaitAsync(tokenRefreshCts.Token).ConfigureAwait(false);

// Test that the client is able to send messages
Logger.Trace($"[{testDevice.Id}]: SendEventAsync (2)");
Logger.Trace($"[{testDevice.Id}]: SendTelemetryAsync (2)");
using var cts2 = new CancellationTokenSource(timeout);
await deviceClient.SendTelemetryAsync(message, cts2.Token).ConfigureAwait(false);
}
Expand Down Expand Up @@ -218,7 +218,7 @@ void ConnectionStatusChangeHandler(ConnectionStatusInfo connectionStatusInfo)
deviceClient.ConnectionStatusChangeCallback = ConnectionStatusChangeHandler;
}

var message = new OutgoingMessage("Hello");
var message = new TelemetryMessage("Hello");

using var cts = new CancellationTokenSource(TimeSpan.FromSeconds(ttl.TotalSeconds * 10));
try
Expand All @@ -227,7 +227,7 @@ void ConnectionStatusChangeHandler(ConnectionStatusInfo connectionStatusInfo)
Logger.Trace($"[{DateTime.UtcNow}] OpenAsync");
await deviceClient.OpenAsync(cts.Token).ConfigureAwait(false);

Logger.Trace($"[{DateTime.UtcNow}] SendEventAsync (1)");
Logger.Trace($"[{DateTime.UtcNow}] SendTelemetryAsync (1)");
await deviceClient.SendTelemetryAsync(message, cts.Token).ConfigureAwait(false);
await refresher.WaitForTokenRefreshAsync(cts.Token).ConfigureAwait(false);
}
Expand All @@ -253,7 +253,7 @@ void ConnectionStatusChangeHandler(ConnectionStatusInfo connectionStatusInfo)

try
{
Logger.Trace($"[{DateTime.UtcNow}] SendEventAsync (2)");
Logger.Trace($"[{DateTime.UtcNow}] SendTelemetryAsync (2)");
await deviceClient.SendTelemetryAsync(message, cts.Token).ConfigureAwait(false);
await refresher.WaitForTokenRefreshAsync(cts.Token).ConfigureAwait(false);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,13 @@ public Task SecurityMessage_ModuleSendSingleMessage_MqttWs()
return TestSecurityMessageModuleAsync(new IotHubClientMqttSettings(IotHubClientTransportProtocol.WebSocket));
}

private OutgoingMessage ComposeD2CSecurityTestMessage()
private TelemetryMessage ComposeD2CSecurityTestMessage()
{
string eventId = Guid.NewGuid().ToString();
string p1Value = eventId;
string payload = ComposeAzureSecurityCenterForIoTSecurityMessagePayload(eventId).ToString(Newtonsoft.Json.Formatting.None);

var message = new OutgoingMessage(payload)
var message = new TelemetryMessage(payload)
{
Properties = { ["property1"] = p1Value }
};
Expand Down Expand Up @@ -155,15 +155,15 @@ private async Task SendSingleSecurityMessageAsync(
{
await deviceClient.OpenAsync().ConfigureAwait(false);

OutgoingMessage testMessage = ComposeD2CSecurityTestMessage();
TelemetryMessage testMessage = ComposeD2CSecurityTestMessage();
await deviceClient.SendTelemetryAsync(testMessage).ConfigureAwait(false);
}

private async Task SendSingleSecurityMessageModuleAsync(
IotHubModuleClient moduleClient)
{
await moduleClient.OpenAsync().ConfigureAwait(false);
OutgoingMessage testMessage = ComposeD2CSecurityTestMessage();
TelemetryMessage testMessage = ComposeD2CSecurityTestMessage();
await moduleClient.SendTelemetryAsync(testMessage).ConfigureAwait(false);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ async Task TestInitAsync(IotHubDeviceClient deviceClient, TestDevice testDevice,

async Task TestOperationAsync(IotHubDeviceClient deviceClient, TestDevice testDevice, TestDeviceCallbackHandler _)
{
OutgoingMessage testMessage = MessageSendE2ETests.ComposeD2cTestMessage(Logger, out string payload, out string p1Value);
TelemetryMessage testMessage = MessageSendE2ETests.ComposeD2cTestMessage(Logger, out string payload, out string p1Value);

Logger.Trace($"{nameof(FaultInjectionPoolAmqpTests)}.{testDevice.Id}: payload='{payload}' p1Value='{p1Value}'");
using var cts = new CancellationTokenSource(TimeSpan.FromSeconds(20));
Expand Down
2 changes: 1 addition & 1 deletion e2e/test/iothub/messaging/MessageSendE2EPoolAmqpTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ async Task InitAsync(IotHubDeviceClient deviceClient, TestDevice t, TestDeviceCa

async Task TestOperationAsync(IotHubDeviceClient deviceClient, TestDevice testDevice, TestDeviceCallbackHandler _)
{
OutgoingMessage testMessage = MessageSendE2ETests.ComposeD2cTestMessage(Logger, out string payload, out string p1Value);
TelemetryMessage testMessage = MessageSendE2ETests.ComposeD2cTestMessage(Logger, out string payload, out string p1Value);
Logger.Trace($"{nameof(MessageSendE2EPoolAmqpTests)}.{testDevice.Id}: messageId='{testMessage.MessageId}' payload='{payload}' p1Value='{p1Value}'");
await deviceClient.SendTelemetryAsync(testMessage).ConfigureAwait(false);
}
Expand Down
16 changes: 8 additions & 8 deletions e2e/test/iothub/messaging/MessageSendE2ETests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ private async Task SendSingleMessageModule(IotHubClientTransportSettings transpo

public static async Task SendSingleMessageAsync(IotHubDeviceClient deviceClient, MsTestLogger logger, int messageSize = 0)
{
OutgoingMessage testMessage = messageSize == 0
TelemetryMessage testMessage = messageSize == 0
? ComposeD2cTestMessage(logger, out string _, out string _)
: ComposeD2cTestMessageOfSpecifiedSize(messageSize, logger, out string _, out string _);

Expand All @@ -209,11 +209,11 @@ public static async Task SendSingleMessageAsync(IotHubDeviceClient deviceClient,

public static async Task SendBatchMessagesAsync(IotHubDeviceClient deviceClient, MsTestLogger logger)
{
var messagesToBeSent = new Dictionary<OutgoingMessage, Tuple<string, string>>();
var messagesToBeSent = new Dictionary<TelemetryMessage, Tuple<string, string>>();

for (int i = 0; i < MessageBatchCount; i++)
{
OutgoingMessage testMessage = ComposeD2cTestMessage(logger, out string payload, out string p1Value);
TelemetryMessage testMessage = ComposeD2cTestMessage(logger, out string payload, out string p1Value);
messagesToBeSent.Add(testMessage, Tuple.Create(payload, p1Value));
}

Expand All @@ -223,7 +223,7 @@ public static async Task SendBatchMessagesAsync(IotHubDeviceClient deviceClient,

private async Task SendSingleMessageModuleAsync(IotHubModuleClient moduleClient)
{
OutgoingMessage testMessage = ComposeD2cTestMessage(Logger, out string _, out string _);
TelemetryMessage testMessage = ComposeD2cTestMessage(Logger, out string _, out string _);

await moduleClient.SendTelemetryAsync(testMessage).ConfigureAwait(false);
}
Expand All @@ -245,15 +245,15 @@ private async Task OpenCloseOpenThenSendSingleMessage(TestDeviceType type, IotHu
await deviceClient.CloseAsync().ConfigureAwait(false);
}

public static OutgoingMessage ComposeD2cTestMessage(MsTestLogger logger, out string payload, out string p1Value)
public static TelemetryMessage ComposeD2cTestMessage(MsTestLogger logger, out string payload, out string p1Value)
{
string messageId = Guid.NewGuid().ToString();
payload = Guid.NewGuid().ToString();
p1Value = Guid.NewGuid().ToString();
string userId = Guid.NewGuid().ToString();

logger.Trace($"{nameof(ComposeD2cTestMessage)}: messageId='{messageId}' userId='{userId}' payload='{payload}' p1Value='{p1Value}'");
var message = new OutgoingMessage(payload)
var message = new TelemetryMessage(payload)
{
MessageId = messageId,
UserId = userId,
Expand All @@ -264,14 +264,14 @@ public static OutgoingMessage ComposeD2cTestMessage(MsTestLogger logger, out str
return message;
}

public static OutgoingMessage ComposeD2cTestMessageOfSpecifiedSize(int messageSize, MsTestLogger logger, out string payload, out string p1Value)
public static TelemetryMessage ComposeD2cTestMessageOfSpecifiedSize(int messageSize, MsTestLogger logger, out string payload, out string p1Value)
{
string messageId = Guid.NewGuid().ToString();
payload = $"{Guid.NewGuid()}_{new string('*', messageSize)}";
p1Value = Guid.NewGuid().ToString();

logger.Trace($"{nameof(ComposeD2cTestMessageOfSpecifiedSize)}: messageId='{messageId}' payload='{payload}' p1Value='{p1Value}'");
var message = new OutgoingMessage(payload)
var message = new TelemetryMessage(payload)
{
MessageId = messageId,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ async Task InitAsync(IotHubDeviceClient deviceClient, TestDevice testDevice)

async Task TestOperationAsync(IotHubDeviceClient deviceClient, TestDevice testDevice)
{
OutgoingMessage testMessage = MessageSendE2ETests.ComposeD2cTestMessage(Logger, out string _, out string _);
TelemetryMessage testMessage = MessageSendE2ETests.ComposeD2cTestMessage(Logger, out string _, out string _);
using var cts = new CancellationTokenSource(operationTimeout);
await deviceClient.SendTelemetryAsync(testMessage, cts.Token).ConfigureAwait(false);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ private static async Task TestDeviceClientInvalidServiceCertificate(IotHubClient
new IotHubDeviceClient(
TestConfiguration.IotHub.DeviceConnectionStringInvalidServiceCertificate,
new IotHubClientOptions(transportSettings));
var testMessage = new OutgoingMessage();
var testMessage = new TelemetryMessage();
await deviceClient.OpenAsync().ConfigureAwait(false);
await deviceClient.SendTelemetryAsync(testMessage).ConfigureAwait(false);
await deviceClient.CloseAsync().ConfigureAwait(false);
Expand Down
4 changes: 2 additions & 2 deletions e2e/test/provisioning/ProvisioningE2ETests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1115,9 +1115,9 @@ private async Task ConfirmRegisteredDeviceWorksAsync(
using var iotClient = new IotHubDeviceClient(result.AssignedHub, auth, new IotHubClientOptions(transportSettings));
Logger.Trace("DeviceClient OpenAsync.");
await iotClient.OpenAsync().ConfigureAwait(false);
Logger.Trace("DeviceClient SendEventAsync.");
Logger.Trace("DeviceClient SendTelemetryAsync.");

var testMessage = new OutgoingMessage("TestMessage");
var testMessage = new TelemetryMessage("TestMessage");
await iotClient.SendTelemetryAsync(testMessage).ConfigureAwait(false);

if (sendReportedPropertiesUpdate)
Expand Down
8 changes: 4 additions & 4 deletions e2e/test/provisioning/ReprovisioningE2ETests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -544,9 +544,9 @@ private async Task ConfirmRegisteredDeviceWorksAsync(
using var deviceClient = new IotHubDeviceClient(result.AssignedHub, auth, new IotHubClientOptions(transportSettings));
Logger.Trace("DeviceClient OpenAsync.");
await deviceClient.OpenAsync().ConfigureAwait(false);
Logger.Trace("DeviceClient SendEventAsync.");
Logger.Trace("DeviceClient SendTelemetryAsync.");

var message = new OutgoingMessage("TestMessage");
var message = new TelemetryMessage("TestMessage");
await deviceClient.SendTelemetryAsync(message).ConfigureAwait(false);

if (transportProtocolSupportsTwinOperations)
Expand Down Expand Up @@ -876,9 +876,9 @@ private async Task ConfirmDeviceWorksAfterReprovisioningAsync(
using var deviceClient = new IotHubDeviceClient(result.AssignedHub, auth, new IotHubClientOptions(transportSettings));
Logger.Trace("DeviceClient OpenAsync.");
await deviceClient.OpenAsync().ConfigureAwait(false);
Logger.Trace("DeviceClient SendEventAsync.");
Logger.Trace("DeviceClient SendTelemetryAsync.");

var testMessage = new OutgoingMessage("TestMessage");
var testMessage = new TelemetryMessage("TestMessage");
await deviceClient.SendTelemetryAsync(testMessage).ConfigureAwait(false);

// Twin can be configured to revert back to default twin when provisioned, or to keep twin
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ private static async Task SendDeviceToCloudMessagesAsync(IotHubDeviceClient devi
humidity = currentHumidity,
pointInfo = infoString
};
var message = new OutgoingMessage(telemetryDataPoint);
var message = new TelemetryMessage(telemetryDataPoint);

// Add one property to the message.
message.Properties.Add("level", levelValue);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ private static async Task SendDeviceToCloudMessagesAsync(IotHubDeviceClient devi
pointInfo = infoString
};

var message = new OutgoingMessage(telemetryDataPoint);
var message = new TelemetryMessage(telemetryDataPoint);

//Add one property to the message.
message.Properties.Add("level", levelValue);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ private static async Task SendDeviceToCloudMessagesAsync(IotHubDeviceClient devi
temperature = currentTemperature,
humidity = currentHumidity,
};
var message = new OutgoingMessage(telemetryDataPoint);
var message = new TelemetryMessage(telemetryDataPoint);

// Add a custom application property to the message.
// An IoT hub can filter on these properties without access to the message body.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ private async Task SendDeviceToCloudMessagesAsync(CancellationToken ct)
temperature = currentTemperature,
humidity = currentHumidity
};
var message = new OutgoingMessage(telemetryDataPoint);
var message = new TelemetryMessage(telemetryDataPoint);

// Add a custom application property to the message.
// An IoT hub can filter on these properties without access to the message body.
Expand Down
Loading

0 comments on commit a776535

Please sign in to comment.