Table of Contents

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

applicationContext ApplicationContext
mqttClient IMqttPubSubClient
serializer IPayloadSerializer

Properties

OnTelemetryReceived

public Func<string, T, IncomingTelemetryMetadata, Task>? OnTelemetryReceived { get; set; }

Property Value

Func<string, T, IncomingTelemetryMetadata, Task>

ServiceGroupId

public string ServiceGroupId { get; init; }

Property Value

string

TopicNamespace

public string? TopicNamespace { get; set; }

Property Value

string

TopicPattern

public string TopicPattern { get; init; }

Property Value

string

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

Dictionary<string, string>

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

ValueTask

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

disposing bool

If true, this call will dispose the underlying mqtt client. If false, this call will not dispose the underlying mqtt client.

Returns

ValueTask

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

disposing bool

If true, this call will dispose the underlying mqtt client. If false, this call will not dispose the underlying mqtt client.

cancellationToken CancellationToken

The cancellation token.

Returns

ValueTask

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

cancellationToken CancellationToken

Returns

ValueTask

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

disposing bool
cancellationToken CancellationToken

Returns

ValueTask

StartAsync(CancellationToken)

Begin accepting telemetry.

public Task StartAsync(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

Cancellation token.

Returns

Task

StopAsync(CancellationToken)

Unsubscribe from any MQTT topics that this client subscribed to

public Task StopAsync(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

Cancellation token

Returns

Task

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.