CoreEx.Azure.Messaging.ServiceBus
4.0.0
dotnet add package CoreEx.Azure.Messaging.ServiceBus --version 4.0.0
NuGet\Install-Package CoreEx.Azure.Messaging.ServiceBus -Version 4.0.0
<PackageReference Include="CoreEx.Azure.Messaging.ServiceBus" Version="4.0.0" />
<PackageVersion Include="CoreEx.Azure.Messaging.ServiceBus" Version="4.0.0" />
<PackageReference Include="CoreEx.Azure.Messaging.ServiceBus" />
paket add CoreEx.Azure.Messaging.ServiceBus --version 4.0.0
#r "nuget: CoreEx.Azure.Messaging.ServiceBus, 4.0.0"
#:package CoreEx.Azure.Messaging.ServiceBus@4.0.0
#addin nuget:?package=CoreEx.Azure.Messaging.ServiceBus&version=4.0.0
#tool nuget:?package=CoreEx.Azure.Messaging.ServiceBus&version=4.0.0
CoreEx.Azure.Messaging.ServiceBus
Provides Azure Service Bus integration for CoreEx: a
ServiceBusPublisherimplementingIEventPublisher, subscriber bases wired toEventSubscriberBase, and receiver hosts with built-in resiliency, metrics, and session support.
Overview
CoreEx.Azure.Messaging.ServiceBus is the Azure Service Bus transport binding for the CoreEx events pipeline. It maps the CloudEvents-based IEventPublisher / EventSubscriberBase abstractions defined in CoreEx.Events directly onto the Azure Service Bus SDK, so no application-level code needs to reference Service Bus types directly.
Publishing is handled by ServiceBusPublisher, which inherits EventPublisherBase and implements OnPublishAsync using the SDK's safe-batch send API. Each DestinationEvent is converted from a CloudEvent to a ServiceBusMessage (structured or binary content mode), with CloudEvents attributes optionally written to message application properties. Session-ID assignment is controlled by the ServiceBusSessionStrategy enum.
Subscribing is layered: ServiceBusSubscriberBase extends EventSubscriberBase to accept a raw ServiceBusReceivedMessage, converting it to a CloudEvent before delegating upward. ServiceBusSubscribedSubscriber adds SubscribedManager dispatch so that [Subscribe]-decorated handlers are resolved automatically from the message subject and source. The ServiceBusReceiver<TSubscriber> and ServiceBusSessionReceiver<TSubscriber> classes wrap the SDK ServiceBusProcessor / ServiceBusSessionProcessor lifetimes, and ServiceBusReceiverHostedService<TReceiver> integrates them with the .NET hosted-service model including pause/resume and health-check support.
Resiliency is provided out-of-the-box: ServiceBusReceiverResiliency supplies factory methods for a receiver-level circuit breaker and a per-message retry pipeline (via Polly), both of which are applied by default in ServiceBusReceiverOptionsBase. Both factories are now thin wrappers over CoreEx.Hosting's generic CircuitBreakerResiliency<TOwner>/RetryResiliency<TOwner> (promoted there so CoreEx.Cosmos's Change Feed Processor-based outbox relay shares the exact same self-pause/self-resume behaviour) - this package supplies only the Service-Bus-specific pause-reason/dead-letter-exclusion/retry-classification wiring.
Key capabilities
- 📤 Safe-batch publishing:
ServiceBusPublishergroupsDestinationEventby destination and sends via the SDK batch API, recording send/fail counters and duration histograms viaServiceBusMetrics. - 🛡 CloudEvents — Service Bus bridge:
ServiceBusExtensionsconvertsCloudEvent—ServiceBusMessage(structured or binary) and back, propagating distributed-tracing headers and CloudEvents attributes as application properties. - 📥 Subscriber dispatch:
ServiceBusSubscribedSubscriberusesSubscribedManagerto route each received message to the correct[Subscribe]-decorated handler by subject and source. - 🔄 Session support:
ServiceBusSessionReceiver<TSubscriber>wrapsServiceBusSessionProcessor;ServiceBusSessionStrategycontrols howEventData.PartitionKeyis mapped to aSessionId(none, as-is, or converted to a bounded partition ID). - 🔧 Hosted-service lifecycle:
ServiceBusReceiverHostedService<TReceiver>integrates the receiver withIHostedService, forwarding start/pause/resume/stop to the underlying processor and reporting degraded health during pause. - 🛡 Built-in resiliency:
ServiceBusReceiverResiliencyprovides a circuit-breaker pipeline (ReceiverResiliency) and a per-message retry pipeline (MessageResiliency) pre-wired into everyServiceBusReceiverOptionsBaseinstance - both delegate toCoreEx.Hosting's genericCircuitBreakerResiliency<TOwner>/RetryResiliency<TOwner>. - 📊 OpenTelemetry metrics:
ServiceBusMetricsexposes aCoreEx.Azure.Messaging.ServiceBusmeter with counters for sent, failed, completed, dead-lettered, and abandoned messages, plus a send-duration histogram;ServiceBusReceiverInvokerwraps receive operations in activity spans. - 📡 Dependency injection helpers:
CoreExServiceBusExtensions(AddAzureServiceBusPublisher,AddAzureServiceBusSubscribedSubscriber,AzureServiceBusReceiving()) andCoreExServiceBusExtensions.AddAzureServiceBusOpenTelemetrywire everything into the DI container with a single fluent call each.
Key types
| Type | Description |
|---|---|
ServiceBusPublisher |
IEventPublisher implementation for Azure Service Bus; sends batched ServiceBusMessage objects, supports structured/binary CloudEvents content mode and session-ID strategies. |
ServiceBusSubscriberBase |
Abstract EventSubscriberBase for Service Bus; accepts a raw ServiceBusReceivedMessage, converts it to a CloudEvent, and provides an OnBeforeReceiveAsync hook. |
ServiceBusSubscribedSubscriber |
Concrete ServiceBusSubscriberBase that uses SubscribedManager to dispatch each message to the matching [Subscribe]-decorated handler. |
ServiceBusReceiver<TSubscriber> |
Manages a ServiceBusProcessor lifetime (start/pause/resume/stop) and delegates each received message to the scoped TSubscriber. |
ServiceBusSessionReceiver<TSubscriber> |
Session-enabled variant of ServiceBusReceiver<TSubscriber>; wraps ServiceBusSessionProcessor. |
ServiceBusReceiverHostedService<TReceiver> |
IHostedService adapter for any ServiceBusReceiverBase; supports pause/resume and reports degraded health while paused. |
ServiceBusReceiverOptions |
Options for ServiceBusReceiver<TSubscriber>; factory methods CreateForQueue / CreateForTopicSubscription; defaults to PeekLock, AutoCompleteMessages=false, MaxConcurrentCalls=1. |
ServiceBusSessionReceiverOptions |
Session-specific options for ServiceBusSessionReceiver<TSubscriber>. |
ServiceBusReceiverResiliency |
Factory for Polly ResiliencePipeline<Result> — CreateReceiverCircuitBreakerResiliency and CreateMessageRetryResiliency; applied by default in ServiceBusReceiverOptionsBase. Thin wrappers over CoreEx.Hosting.CircuitBreakerResiliency<TOwner>/RetryResiliency<TOwner>. |
ServiceBusSessionStrategy |
Enum: None, UsePartitionKeyAsIs, UsePartitionKeyConvertedToAnId; controls how the publisher assigns a SessionId to each outbound message. |
| IServiceBusMessageActions | Defines complete/abandon/dead-letter/defer actions for a received message; implemented by ProcessMessageEventArgsActions and ProcessSessionMessageEventArgsActions in the Abstractions folder. |
ServiceBusMetrics |
Static class exposing the CoreEx.Azure.Messaging.ServiceBus Meter with send/receive counters and a send-duration histogram. |
ServiceBusExtensions |
Extension methods for converting CloudEvent to/from ServiceBusMessage in structured or binary content mode. |
Namespaces
| Namespace | Description | Documentation |
|---|---|---|
CoreEx.Azure.Messaging.ServiceBus.Abstractions |
Base receiver infrastructure: ServiceBusReceiverBase, typed ServiceBusReceiverBase<TSubscriber>, ServiceBusReceiverOptionsBase, ServiceBusMessageActionsBase, message-actions adapters, and ServiceBusErrorClassifier. |
📖 README |
Related namespaces
CoreEx.Events- DefinesIEventPublisher,EventPublisherBase,EventSubscriberBase,SubscribedManager, andIEventFormatterthat this package binds to Azure Service Bus.CoreEx.Events.Publishing-IDestinationProviderandDestinationEventused byServiceBusPublisherduring batched dispatch.CoreEx.Events.Subscribing-ErrorHandling,ErrorHandler, and subscriber exception types consumed by the receiver pipeline.CoreEx.Database.Outbox- Outbox relay publisher that produces events later consumed by aServiceBusReceiver-based relay host.CoreEx.Hosting-CircuitBreakerResiliency<TOwner>/RetryResiliency<TOwner>are the generic self-pausing/retry pipelines thatServiceBusReceiverResiliencynow delegates to; originally implemented here, promoted for reuse byCoreEx.Cosmos's outbox relay.
AI Usage Guide
An AGENTS.md file is included with this package. AI coding assistants (GitHub Copilot, Claude, Cursor, etc.) that support workspace-injected package documentation will automatically surface concise usage guidance, code examples, and Do Not rules for this package without requiring a local CoreEx checkout.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. 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 is compatible. 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 is compatible. 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. |
-
net10.0
- Aspire.Azure.Messaging.ServiceBus (>= 13.5.4)
- CoreEx.Events (>= 4.0.0)
-
net8.0
- Aspire.Azure.Messaging.ServiceBus (>= 13.5.4)
- CoreEx.Events (>= 4.0.0)
-
net9.0
- Aspire.Azure.Messaging.ServiceBus (>= 13.5.4)
- CoreEx.Events (>= 4.0.0)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on CoreEx.Azure.Messaging.ServiceBus:
| Package | Downloads |
|---|---|
|
CoreEx.UnitTesting
Core .NET extensions and abstractions for the testing of backend services. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 4.0.0 | 46 | 9/21/2026 |
| 4.0.0-preview-5 | 108 | 8/23/2026 |
| 4.0.0-preview-4 | 89 | 8/21/2026 |
| 4.0.0-preview-3 | 140 | 8/4/2026 |
| 4.0.0-preview-2 | 102 | 7/10/2026 |
| 4.0.0-preview-1 | 127 | 6/20/2026 |