Table of Contents

Class TelemetrySender<T>

Namespace
Azure.Iot.Operations.Protocol.Telemetry
Assembly
Azure.Iot.Operations.Protocol.dll
public abstract class TelemetrySender<T> : IAsyncDisposable where T : class

Type Parameters

T
Inheritance
TelemetrySender<T>
Implements
Inherited Members

Constructors

TelemetrySender(ApplicationContext, IMqttPubSubClient, IPayloadSerializer)

public TelemetrySender(ApplicationContext applicationContext, IMqttPubSubClient mqttClient, IPayloadSerializer serializer)

Parameters

applicationContext ApplicationContext
mqttClient IMqttPubSubClient
serializer IPayloadSerializer

Properties

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 telemetry sender 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 command invoker's lifetime.

public Dictionary<string, string> TopicTokenMap { get; protected set; }

Property Value

Dictionary<string, string>

Remarks

Tokens replacement values can also be specified per-telemetry by specifying the additionalTopicToken map in SendTelemetryAsync(T, MqttQualityOfServiceLevel, TimeSpan?, CancellationToken).

Methods

DisposeAsync()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources asynchronously.

public virtual ValueTask DisposeAsync()

Returns

ValueTask

A task that represents the asynchronous dispose operation.

DisposeAsync(bool)

public virtual ValueTask DisposeAsync(bool disposing)

Parameters

disposing bool

Returns

ValueTask

DisposeAsyncCore(bool)

protected virtual ValueTask DisposeAsyncCore(bool disposing)

Parameters

disposing bool

Returns

ValueTask

SendTelemetryAsync(T, OutgoingTelemetryMetadata, Dictionary<string, string>?, MqttQualityOfServiceLevel, TimeSpan?, CancellationToken)

Send telemetry with custom metadata.

public Task SendTelemetryAsync(T telemetry, OutgoingTelemetryMetadata metadata, Dictionary<string, string>? additionalTopicTokenMap = null, MqttQualityOfServiceLevel qos = MqttQualityOfServiceLevel.AtLeastOnce, TimeSpan? telemetryTimeout = null, CancellationToken cancellationToken = default)

Parameters

telemetry T

The payload of the telemetry.

metadata OutgoingTelemetryMetadata

The telemetry metadata.

additionalTopicTokenMap Dictionary<string, string>

The topic token replacement map to use in addition to TopicTokenMap.If this map contains any keys that TopicTokenMap also has, then values specified in this map will take precedence.

qos MqttQualityOfServiceLevel

The quality of service to send the telemetry with.

telemetryTimeout TimeSpan?

How long the telemetry message will be available on the broker for a receiver to receive.

cancellationToken CancellationToken

Cancellation token.

Returns

Task

SendTelemetryAsync(T, Dictionary<string, string>?, MqttQualityOfServiceLevel, TimeSpan?, CancellationToken)

Send telemetry with the default metadata.

public Task SendTelemetryAsync(T telemetry, Dictionary<string, string>? additionalTopicTokenMap = null, MqttQualityOfServiceLevel qos = MqttQualityOfServiceLevel.AtLeastOnce, TimeSpan? telemetryTimeout = null, CancellationToken cancellationToken = default)

Parameters

telemetry T

The payload of the telemetry.

additionalTopicTokenMap Dictionary<string, string>

The topic token replacement map to use in addition to TopicTokenMap.If this map contains any keys that TopicTokenMap also has, then values specified in this map will take precedence.

qos MqttQualityOfServiceLevel

The quality of service to send the telemetry with.

telemetryTimeout TimeSpan?

How long the telemetry message will be available on the broker for a receiver to receive.

cancellationToken CancellationToken

Cancellation token.

Returns

Task