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
ApplicationContextlogger
ILogger<TelemetryConnectorWorker>mqttClient
IMqttClientmessageSchemaProviderFactory
IMessageSchemaProviderassetMonitor
IAssetMonitorleaderElectionConfigurationProvider
IConnectorLeaderElectionConfigurationProvider
Fields
OnAssetAvailable
Event handler for when an asset becomes available.
public EventHandler<AssetAvailabileEventArgs>? OnAssetAvailable
Field Value
OnAssetUnavailable
Event handler for when an asset becomes unavailable.
public EventHandler<AssetUnavailableEventArgs>? OnAssetUnavailable
Field Value
_logger
protected readonly ILogger<TelemetryConnectorWorker> _logger
Field Value
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
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
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
AssetassetEvent
EventserializedPayload
byte[]cancellationToken
CancellationToken
Returns
ForwardSampledDatasetAsync(Asset, Dataset, byte[], CancellationToken)
public Task ForwardSampledDatasetAsync(Asset asset, Dataset dataset, byte[] serializedPayload, CancellationToken cancellationToken = default)
Parameters
asset
Assetdataset
DatasetserializedPayload
byte[]cancellationToken
CancellationToken
Returns
RunConnectorAsync(CancellationToken)
Run the connector worker.
public override Task RunConnectorAsync(CancellationToken cancellationToken = default)
Parameters
cancellationToken
CancellationTokenCancellation token.
Returns
Remarks
This will run the connector until the provided cancellation token is cancelled.