Table of Contents

Class TelemetryConnectorWorker

Namespace
Azure.Iot.Operations.Connector
Assembly
Azure.Iot.Operations.Connector.dll

Base class for a connector worker that allows users to forward data samplied from datasets and forwarding of received events.

public class TelemetryConnectorWorker : ConnectorBackgroundService, IHostedService, IDisposable
Inheritance
TelemetryConnectorWorker
Implements
Derived
Inherited Members

Constructors

TelemetryConnectorWorker(ApplicationContext, ILogger<TelemetryConnectorWorker>, IMqttClient, IMessageSchemaProvider, IAssetMonitor, IConnectorLeaderElectionConfigurationProvider?)

public TelemetryConnectorWorker(ApplicationContext applicationContext, ILogger<TelemetryConnectorWorker> logger, IMqttClient mqttClient, IMessageSchemaProvider messageSchemaProviderFactory, IAssetMonitor assetMonitor, IConnectorLeaderElectionConfigurationProvider? leaderElectionConfigurationProvider = null)

Parameters

applicationContext ApplicationContext
logger ILogger<TelemetryConnectorWorker>
mqttClient IMqttClient
messageSchemaProviderFactory IMessageSchemaProvider
assetMonitor IAssetMonitor
leaderElectionConfigurationProvider IConnectorLeaderElectionConfigurationProvider

Fields

OnAssetAvailable

Event handler for when an asset becomes available.

public EventHandler<AssetAvailabileEventArgs>? OnAssetAvailable

Field Value

EventHandler<AssetAvailabileEventArgs>

OnAssetUnavailable

Event handler for when an asset becomes unavailable.

public EventHandler<AssetUnavailableEventArgs>? OnAssetUnavailable

Field Value

EventHandler<AssetUnavailableEventArgs>

_logger

protected readonly ILogger<TelemetryConnectorWorker> _logger

Field Value

ILogger<TelemetryConnectorWorker>

Properties

AssetEndpointProfile

The asset endpoint profile associated with this connector. This will be null until the asset endpoint profile is first discovered.

public AssetEndpointProfile? AssetEndpointProfile { get; set; }

Property Value

AssetEndpointProfile

Methods

Dispose()

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

public override void Dispose()

ExecuteAsync(CancellationToken)

This method is called when the IHostedService starts. The implementation should return a task that represents the lifetime of the long running operation(s) being performed.

protected override Task ExecuteAsync(CancellationToken cancellationToken)

Parameters

cancellationToken CancellationToken

Returns

Task

A Task that represents the long running operations.

Remarks

See Worker Services in .NET for implementation guidelines.

ForwardReceivedEventAsync(Asset, Event, byte[], CancellationToken)

public Task ForwardReceivedEventAsync(Asset asset, Event assetEvent, byte[] serializedPayload, CancellationToken cancellationToken = default)

Parameters

asset Asset
assetEvent Event
serializedPayload byte[]
cancellationToken CancellationToken

Returns

Task

ForwardSampledDatasetAsync(Asset, Dataset, byte[], CancellationToken)

public Task ForwardSampledDatasetAsync(Asset asset, Dataset dataset, byte[] serializedPayload, CancellationToken cancellationToken = default)

Parameters

asset Asset
dataset Dataset
serializedPayload byte[]
cancellationToken CancellationToken

Returns

Task

RunConnectorAsync(CancellationToken)

Run the connector worker.

public override Task RunConnectorAsync(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

Cancellation token.

Returns

Task

Remarks

This will run the connector until the provided cancellation token is cancelled.