CoreEx.Events
4.3.0
dotnet add package CoreEx.Events --version 4.3.0
NuGet\Install-Package CoreEx.Events -Version 4.3.0
<PackageReference Include="CoreEx.Events" Version="4.3.0" />
<PackageVersion Include="CoreEx.Events" Version="4.3.0" />
<PackageReference Include="CoreEx.Events" />
paket add CoreEx.Events --version 4.3.0
#r "nuget: CoreEx.Events, 4.3.0"
#:package CoreEx.Events@4.3.0
#addin nuget:?package=CoreEx.Events&version=4.3.0
#tool nuget:?package=CoreEx.Events&version=4.3.0
CoreEx.Events
Provides the CoreEx event publishing and subscribing infrastructure:
EventData↔ CloudEvents formatting, a two-phase queue-then-publish pipeline, and configurable subscriber dispatch with structured error handling.
Overview
CoreEx.Events is the messaging backbone of the CoreEx framework. It defines the contracts and base implementations used by every host that sends or receives integration events — whether those are Azure Service Bus messages, outbox-relayed events, or any other transport.
Publishing follows a two-phase pattern: application code buffers EventData (or CloudEvent) objects into a lightweight in-process queue, then a single PublishAsync() call drains the queue to the underlying transport atomically. An IDestinationProvider resolves topic/queue names from event metadata, and IEventFormatter converts between EventData and the CloudNative CloudEvents specification, attaching trace parent/state automatically; ambient baggage capture requires explicit opt-in.
Subscribing is built around EventSubscriberBase, which receives a CloudEvent from the host transport, converts it back to EventData via IEventFormatter, and dispatches to the matching SubscribedBase handler registered with a SubscribedManager. Every error path — transient retries, dead-letter, silent completion, catastrophic failure — is expressed as a configurable ErrorHandling enum value, keeping subscriber code free of try/catch scaffolding.
Typed payload cleanup is available through EventSubscriberBase.AutoCleanValue (default false) and a nullable per-handler SubscribedBase.AutoCleanValue override. Unlike WebApi request input, published events are generally expected to be canonical already, so consumer cleanup is typically redundant and can reinterpret producer-owned facts. Enable it deliberately where the receiving boundary owns normalization; see cleanup behavior and overrides.
Key capabilities
- 🔄
EventData↔ CloudEvents bridge:IEventFormatter/EventFormatterconvert between the CoreExEventDataenvelope and the CloudNative CloudEvents spec, including automatic trace parent/state propagation and explicit baggage policies. - 🔗 Outbox relay trace-linking:
CloudEventTracingExtensions.LinkTraceContextreads a previously-stored event'straceparent/tracestateextension attributes back out and adds them as anActivityLinkon the currentActivity- used by an outbox relay to connect its own publish span back to each original producer's trace (deliberately does not propagatebaggage; see the XML doc remarks for why a batched, fan-in relay can't do that safely). Shared unchanged byCoreEx.Database.OutboxandCoreEx.Cosmos.Outbox's relays. - 🧹 App-wide payload redaction:
EventFormatter.DataExcludePathsapplies aCoreEx.Json.JsonFilterexclude (recursive descent, e.g.$..etag) to every event'sDataduringFormat(), so a property can be stripped from all published events in one place rather than at everyEventData.WithValue()call site. Defaults to excluding$..etag— an optimistic-concurrency token that has no meaning to a downstream consumer and cannot be reliably captured for events raised transactionally via an outbox against a NoSQL store; set tonull/empty to opt out. - 📤 Queue-then-publish pipeline: Events are buffered in-process and dispatched atomically via
PublishAsync();Rollback(count)andReset()support outbox and retry patterns. - 📍 Destination resolution:
IDestinationProviderdynamically generates topic/queue names from anEventData, an explicit destination string, or fromMessageTypeand domain name. - 📥 Structured subscriber dispatch:
SubscribedManagerroutes incoming events to[Subscribe]-decorated handlers, enforces inbox idempotency checks, and manages ambiguous- and not-subscribed outcomes. - 🛡️ Configurable error handling:
ErrorHandlingenum values (CompleteAsSilent,Retry,DeadLetter,Catastrophic, and more) are mapped per exception type via a fluentErrorHandlerconfigurator — no boilerplate try/catch in subscriber code. - 📊 OpenTelemetry metrics:
EventSubscriberMetricsexposes amessages.receivedcounter viaSystem.Diagnostics.Metrics;EventPublisherInvokerandSubscribedInvokerwrap operations in activity spans. - 🧩
MessageTypediscrimination: DistinguishesEvent,Command, andReplyTosemantics for destination-name generation.
Baggage policy and 4.4 migration
Behavior change for 4.4: incoming CloudEvent baggage is no longer automatically imported into Activity.Current, and publishing no longer automatically captures ambient activity baggage. Trace parent/state capture and producer linking remain automatic; message processing, validation and settlement are unchanged.
Enable receive propagation on the owning EventSubscriberBase (including ServiceBusSubscribedSubscriber or ServiceBusSubscriberBase<TValue>) with PropagateBaggage = true. This single policy covers both CloudEvent envelopes and native Service Bus application properties. The shared EventBaggage parser/importer rejects encoded headers over 8192 UTF-8 bytes, considers at most 64 entries per import, bounds decoded imports by their encoded size, and preserves all existing activity baggage keys. Malformed/oversized tracing metadata does not reject otherwise-valid event data. Transport metadata is imported first, so it wins over duplicate envelope keys when enabled. Baggage propagation does not require a trace parent and never creates an activity or authenticated tenant/user context.
Enable ambient capture separately with AddEventFormatter(formatter => formatter.CaptureBaggage = true). Explicit EventData.TraceBaggage, explicit AddTracing(..., traceBaggage: ...) arguments and baggage already present in a supplied CloudEvent remain intentional wire data, independent of ambient capture. Parsing an envelope retains bounded EventData.TraceBaggage even when activity import is disabled; the setting controls propagation, not removal of message metadata. Only opt in for trusted producers and approved baggage keys: baggage flows to downstream dependencies and can contain sensitive data.
Outbox relay batch activities continue to link originating traces without importing any event's baggage, avoiding cross-event leakage. Formatter-configured trace attribute names are honored by envelope conversion; Service Bus transport mirroring and relay extraction still recognize standard trace names, so use the defaults for end-to-end transport/relay tracing.
Key types
| Type | Description |
|---|---|
IEventFormatter |
Formats/parses EventData, converts to/from CloudEvent, adds distributed-tracing headers. |
EventFormatter |
Default IEventFormatter implementation; handles CloudEvents attribute mapping, trace propagation, and (via DataExcludePaths) app-wide JsonFilter-based redaction of the event Data payload. |
MessageType |
Enum: Event, Command, ReplyTo — used in destination-name generation. |
CloudEventTracingExtensions |
LinkTraceContext(Activity?, IEnumerable<CloudEvent>) - links an activity to each event's originating W3C trace context; used by an outbox relay's publish span, not by ordinary publishing. |
Namespaces
| Namespace | Description | Documentation |
|---|---|---|
CoreEx.Events.Publishing |
Two-phase queue-then-publish pipeline: IEventQueue, IEventPublisher, EventPublisherBase, IDestinationProvider, DestinationEvent, NoOpEventPublisher. |
📖 README |
CoreEx.Events.Subscribing |
Subscriber dispatch and error handling: EventSubscriberBase, SubscribedManager, SubscribedBase, ErrorHandler, ErrorHandling, subscriber exceptions. |
📖 README |
Related namespaces
CoreEx- DefinesEventData,CloudEventinterop,ExecutionContext, andResult<T>used throughout the events pipeline.CoreEx.Database.Outbox/CoreEx.Cosmos.Outbox- Outbox-pattern publishers that wrapIEventPublisher; persist events transactionally (relational outbox table / Cosmos DBTransactionalBatch) and relay them via a background host (poll-loop / Change Feed Processor), sharing the sameCloudEventTracingExtensionsand harmonized metric naming.CoreEx.DomainDriven-Aggregate<TId, TSelf>accumulatesEventDatainternally; the application layer forwards those to the publishing queue within the same unit-of-work.CoreEx.Invokers-EventPublisherInvokerandSubscribedInvokerprovide OpenTelemetry activity wrapping for publish and receive operations.
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
- CloudNative.CloudEvents.SystemTextJson (>= 2.9.0)
- CoreEx (>= 4.3.0)
-
net8.0
- CloudNative.CloudEvents.SystemTextJson (>= 2.9.0)
- CoreEx (>= 4.3.0)
-
net9.0
- CloudNative.CloudEvents.SystemTextJson (>= 2.9.0)
- CoreEx (>= 4.3.0)
NuGet packages (5)
Showing the top 5 NuGet packages that depend on CoreEx.Events:
| Package | Downloads |
|---|---|
|
CoreEx.UnitTesting
Core .NET extensions and abstractions for the testing of backend services. |
|
|
CoreEx.Data
Core .NET extensions and abstractions for the development of backend services. |
|
|
CoreEx.Cosmos
Core .NET extensions and abstractions for the development of backend services. |
|
|
CoreEx.Azure.Messaging.ServiceBus
Core .NET extensions and abstractions for the development of backend services. |
|
|
CoreEx.DomainDriven
Core .NET extensions and abstractions for the development of backend services. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 4.3.0 | 0 | 11/6/2026 |
| 4.2.0 | 302 | 10/24/2026 |
| 4.1.0 | 274 | 10/12/2026 |
| 4.0.0 | 301 | 9/21/2026 |
| 4.0.0-preview-5 | 333 | 8/23/2026 |
| 4.0.0-preview-4 | 308 | 8/21/2026 |
| 4.0.0-preview-3 | 395 | 8/4/2026 |
| 4.0.0-preview-2 | 294 | 7/10/2026 |
| 4.0.0-preview-1 | 280 | 6/20/2026 |