Hsm.OperationalContextService.ServiceBusClient
1.0.0-alpha.3
This is a prerelease version of Hsm.OperationalContextService.ServiceBusClient.
dotnet add package Hsm.OperationalContextService.ServiceBusClient --version 1.0.0-alpha.3
NuGet\Install-Package Hsm.OperationalContextService.ServiceBusClient -Version 1.0.0-alpha.3
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Hsm.OperationalContextService.ServiceBusClient" Version="1.0.0-alpha.3" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Hsm.OperationalContextService.ServiceBusClient" Version="1.0.0-alpha.3" />
<PackageReference Include="Hsm.OperationalContextService.ServiceBusClient" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Hsm.OperationalContextService.ServiceBusClient --version 1.0.0-alpha.3
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Hsm.OperationalContextService.ServiceBusClient, 1.0.0-alpha.3"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Hsm.OperationalContextService.ServiceBusClient@1.0.0-alpha.3
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Hsm.OperationalContextService.ServiceBusClient&version=1.0.0-alpha.3&prerelease
#tool nuget:?package=Hsm.OperationalContextService.ServiceBusClient&version=1.0.0-alpha.3&prerelease
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Hsm.OperationalContextService.ServiceBusClient
A .NET client library for communicating with the Hsm Operational Context Service over Azure Service Bus, providing request-response and pub-sub messaging patterns for activation and deactivation operations.
Overview
This package provides implementations for sending requests and processing responses from the Operational Context Service using Azure Service Bus. It includes strongly-typed clients for:
- Activation Requests: Request activation of a device with specific properties
- Deactivation Requests: Request deactivation of a device
Use
using System.Text.Json;
using Microsoft.Extensions.DependencyInjection;
using Hsm.OperationalContextService.ServiceBusClient.Configuration;
using Hsm.OperationalContextService.ServiceBusClient.Extensions;
using Hsm.OperationalContextService.ServiceBusClient.Abstractions.Client;
using Hsm.OperationalContextService.ServiceBusClient.Abstractions.Messages.V1.Models;
using Hsm.OperationalContextService.ServiceBusClient.Abstractions.Messages.Enums;
using Hsm.OperationalContextService.ServiceBusClient.Abstractions.Subscriber;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
var serviceCollection = new ServiceCollection();
serviceCollection.AddLogging(builder => { builder.AddConsole(); });
var configuration = new ConfigurationBuilder()
.AddUserSecrets<Program>()
.Build();
var serviceBusConfig = new OperationalContextServiceServiceBusConfiguration();
configuration.GetRequiredSection(nameof(OperationalContextServiceServiceBusConfiguration)).Bind(serviceBusConfig);
serviceCollection.AddOperationalContextClient(serviceBusConfig, new());
var serviceProvider = serviceCollection.BuildServiceProvider();
var activationClient = serviceProvider.GetRequiredService<IActivationRequestClientV1>();
// deactivationClient is handled exactly the same as activationClient so skipped in this example
var deactivationClient = serviceProvider.GetRequiredService<IDeactivationRequestClientV1>();
var messageProcessor = serviceProvider.GetRequiredService<IServiceBusMessageProcessor>();
var logger = serviceProvider.GetRequiredService<ILogger<Program>>();
//1) register handlers in Client
activationClient.AcceptedEventHandler += (_, args) => LogResponseAsync(args);
activationClient.RejectedEventHandler += (_, args) => LogResponseAsync(args);
activationClient.SucceededEventHandler += (_, args) => LogResponseAsync(args);
activationClient.FailedEventHandler += (_, args) => LogResponseAsync(args);
//2) start processing of messages.
// Any clients not yet setup will have their messages discarded (eg in this example all DeactivationMessages would be discarded)
// this is needed because those deactivation messages may block ActivationMessages from execution
await messageProcessor.StartProcessingMessagesAsync();
try
{
//Requests are processed serverside one by one to maintain ordering.
// if you run in timeouts decrease request-volume or increase the timeout in the configuration
var response = await activationClient.SendRequestAsync(
new ActivationRequestMessageV1(
CorrelationId: Guid.NewGuid(),
DeviceId: Guid.NewGuid(),
CountryCode: "AT",
TimeZone: "America/New_York",
Label: "ServiceBusClient.Example - auto-created",
DeviceRole: DeviceRole.Stable
));
if (!response.IsSuccess)
{
logger.LogInformation("Activation request was rejected: {Serialized}",
JsonSerializer.Serialize(response.RejectedMessage));
}
else
{
logger.LogInformation("Activation request was accepted: {Serialized}",
JsonSerializer.Serialize(response.AcceptedMessage));
}
// So we can see further messages in the logs
await Task.Delay(TimeSpan.FromMinutes(1));
}
catch (TimeoutException ex)
{
logger.LogInformation("No response received within timeout: {ExMessage}", ex.Message);
}
catch (Exception ex)
{
logger.LogInformation("An error occurred: {ExMessage}", ex.Message);
}
Task LogResponseAsync<T>(CorrelatedMessageEventArgs<T> correlatedMessageEventArgs)
where T : ICorrelatedMessage
{
logger.LogInformation("{Name}: {Serialized}", typeof(T).Name,
JsonSerializer.Serialize(correlatedMessageEventArgs.Message));
return Task.CompletedTask;
}
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.1 is compatible. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
.NETStandard 2.1
- Azure.Messaging.ServiceBus (>= 7.20.1)
- Hsm.OperationalContextService.ServiceBusClient.Abstractions (>= 1.0.0-alpha.3)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.5)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.5)
- Newtonsoft.Json (>= 13.0.4)
- System.Text.Json (>= 10.0.5)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.0-alpha.3 | 139 | 3/27/2026 |
| 1.0.0-alpha.2 | 77 | 3/18/2026 |
| 1.0.0-alpha.1 | 37 | 3/18/2026 |
| 1.0.0-alpha.0 | 40 | 3/18/2026 |