Class TelemetryReceiver<T>
- Namespace
- Azure.Iot.Operations.Protocol.Telemetry
- Assembly
- Azure.Iot.Operations.Protocol.dll
public abstract class TelemetryReceiver<T> : IAsyncDisposable where T : class
Type Parameters
T
- Inheritance
-
TelemetryReceiver<T>
- Implements
- Derived
- Inherited Members
Constructors
TelemetryReceiver(ApplicationContext, IMqttPubSubClient, IPayloadSerializer)
public TelemetryReceiver(ApplicationContext applicationContext, IMqttPubSubClient mqttClient, IPayloadSerializer serializer)
Parameters
applicationContextApplicationContextmqttClientIMqttPubSubClientserializerIPayloadSerializer
Properties
OnTelemetryReceived
public Func<string, T, IncomingTelemetryMetadata, Task>? OnTelemetryReceived { get; set; }
Property Value
ServiceGroupId
public string ServiceGroupId { get; init; }
Property Value
TopicNamespace
public string? TopicNamespace { get; set; }
Property Value
TopicPattern
public string TopicPattern { get; init; }
Property Value
TopicTokenMap
The topic token replacement map that this receiver will use by default. Generally, this will include the token values for topic tokens such as "modelId" which should be the same for the duration of this receiver's lifetime.
public Dictionary<string, string> TopicTokenMap { get; protected set; }
Property Value
Remarks
Tokens replacement values can also be specified when starting the receiver by specifying the additionalTopicToken map in StartAsync(Dictionary<string, string>?, CancellationToken).
Methods
DisposeAsync()
Asynchronously dispose this object, but not the underlying mqtt client.
public virtual ValueTask DisposeAsync()
Returns
Remarks
Users are advised to call StopAsync(CancellationToken) prior to this in order to cleanup any MQTT subscriptions that this client has.
To also dispose the underlying mqtt client, use DisposeAsync(bool).
DisposeAsync(bool)
Asynchronously dispose this object and optionally dispose the underlying mqtt client as well.
public virtual ValueTask DisposeAsync(bool disposing)
Parameters
disposingboolIf true, this call will dispose the underlying mqtt client. If false, this call will not dispose the underlying mqtt client.
Returns
Remarks
Users are advised to call StopAsync(CancellationToken) prior to this in order to cleanup any MQTT subscriptions that this client has.
DisposeAsync(bool, CancellationToken)
Asynchronously dispose this object and optionally dispose the underlying mqtt client as well.
public virtual ValueTask DisposeAsync(bool disposing, CancellationToken cancellationToken)
Parameters
disposingboolIf true, this call will dispose the underlying mqtt client. If false, this call will not dispose the underlying mqtt client.
cancellationTokenCancellationTokenThe cancellation token.
Returns
Remarks
Users are advised to call StopAsync(CancellationToken) prior to this in order to cleanup any MQTT subscriptions that this client has.
DisposeAsync(CancellationToken)
Asynchronously dispose this object, but not the underlying mqtt client.
public virtual ValueTask DisposeAsync(CancellationToken cancellationToken)
Parameters
cancellationTokenCancellationToken
Returns
Remarks
Users are advised to call StopAsync(CancellationToken) prior to this in order to cleanup any MQTT subscriptions that this client has.
To also dispose the underlying mqtt client, use DisposeAsync(bool, CancellationToken).
DisposeAsyncCore(bool, CancellationToken)
protected virtual ValueTask DisposeAsyncCore(bool disposing, CancellationToken cancellationToken)
Parameters
disposingboolcancellationTokenCancellationToken
Returns
StartAsync(CancellationToken)
Begin accepting telemetry.
public Task StartAsync(CancellationToken cancellationToken = default)
Parameters
cancellationTokenCancellationTokenCancellation token.
Returns
StopAsync(CancellationToken)
Unsubscribe from any MQTT topics that this client subscribed to
public Task StopAsync(CancellationToken cancellationToken = default)
Parameters
cancellationTokenCancellationTokenCancellation token
Returns
Remarks
This operation does require the underlying MQTT client to be connected to complete, so users are advised to pass in a cancellation token to protect against the case where the underlying MQTT client gets disconnected and takes an unexpectedly long time to reconnect.