Fudie.PubSub 1.0.12

dotnet add package Fudie.PubSub --version 1.0.12
                    
NuGet\Install-Package Fudie.PubSub -Version 1.0.12
                    
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="Fudie.PubSub" Version="1.0.12" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Fudie.PubSub" Version="1.0.12" />
                    
Directory.Packages.props
<PackageReference Include="Fudie.PubSub" />
                    
Project file
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 Fudie.PubSub --version 1.0.12
                    
#r "nuget: Fudie.PubSub, 1.0.12"
                    
#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 Fudie.PubSub@1.0.12
                    
#: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=Fudie.PubSub&version=1.0.12
                    
Install as a Cake Addin
#tool nuget:?package=Fudie.PubSub&version=1.0.12
                    
Install as a Cake Tool

Fudie.PubSub

Messaging core for the Fudie platform. Defines contracts, abstractions, and the hosting layer. Does not contain any provider implementation.

Structure

Fudie.PubSub/
  Transport/        Transport contracts (publish, subscribe, admin)
  Serialization/    Serialization contract and default implementation
  Messaging/        Envelope, message context, and high-level publisher
  Hosting/          Handler, MessageHost, and DI configuration

Transport

Segregated interfaces for transport operations:

Interface Responsibility
IPublisher Publish messages to a topic
ISubscriber Subscribe to messages from a subscription
ITopicAdmin Create, delete, and check topics
ISubscriptionAdmin Create, delete, and check subscriptions
IPubSubClient Composite interface grouping all of the above

PubSubClient is the abstract base class implementing IPubSubClient with argument validation. Providers inherit from it.

Serialization

public interface ISerializer
{
    byte[] Serialize<T>(T value);
    T Deserialize<T>(byte[] data);
}

JsonPubSubSerializer is the default implementation using System.Text.Json. If no ISerializer is registered in DI, the provider uses this implementation automatically.

Messaging

Envelope

Each message travels wrapped in an Envelope<T>:

public record Envelope<T>(
    string MessageId,
    string? CorrelationId,
    string Type,
    DateTime OccurredAt,
    IDictionary<string, string>? Claims,
    T Payload
);

Developers never interact with the envelope directly. MessagePublisher builds it when publishing and MessageHost unwraps it when receiving.

IMessageContext

Scoped context exposing data from the current message:

public interface IMessageContext
{
    string? TenantId { get; }
    string? UserId { get; }
    string? CorrelationId { get; }
    IDictionary<string, string> Claims { get; }
}

Injected into handlers, DbContexts (for multi-tenant QueryFilters), and any scoped service. Automatically populated from:

  • HTTP middleware (JWT claims)
  • Outbox worker (stored claims)
  • MessageHost (envelope claims when receiving a message)

MessagePublisher

IMessagePublisher is the high-level interface for publishing messages:

public interface IMessagePublisher
{
    Task PublishAsync<T>(string topicId, T message);
}

Wraps T in Envelope<T> using claims from the current IMessageContext.

Hosting

IMessageHandler<T>

Contract for consuming messages:

public interface IMessageHandler<in T>
{
    Task Handle(T message, CancellationToken ct);
}

MessageHost

Orchestrates message reception. For each message:

  1. Creates a DI scope
  2. Populates MessageContext with claims and correlationId from the envelope
  3. Resolves IMessageHandler<T> within the scope
  4. Executes the handler

This ensures each message has its own scope with independent IMessageContext and DbContext.

Configuration

builder.Services.AddPubSubMessaging(pubsub =>
{
    pubsub.UseGcp(builder.Configuration);  // provider extension
});

AddPubSubMessaging registers:

Service Lifetime
MessageContext / IMessageContext Scoped
IMessagePublisher Scoped
MessageHost Singleton

The provider (e.g. UseGcp) registers IPubSubClient as Singleton.

Dependencies

This project has no provider dependencies. It only depends on:

  • Microsoft.Extensions.DependencyInjection.Abstractions
Product 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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Fudie.PubSub:

Package Downloads
Fudie

Fudie framework — all packages in one reference. Install this to get the full framework.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.12 108 3/8/2026
1.0.11 108 3/7/2026
1.0.10 108 3/5/2026
1.0.9 102 3/5/2026
1.0.8 101 3/5/2026
1.0.7 111 3/4/2026
1.0.6 104 3/4/2026
1.0.5 102 3/4/2026
1.0.4 115 3/3/2026
1.0.3 109 3/3/2026
1.0.2 105 3/3/2026
1.0.1 109 3/2/2026
1.0.0 106 3/2/2026