EasyCore.Pulsar 8.3.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package EasyCore.Pulsar --version 8.3.0
                    
NuGet\Install-Package EasyCore.Pulsar -Version 8.3.0
                    
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="EasyCore.Pulsar" Version="8.3.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="EasyCore.Pulsar" Version="8.3.0" />
                    
Directory.Packages.props
<PackageReference Include="EasyCore.Pulsar" />
                    
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 EasyCore.Pulsar --version 8.3.0
                    
#r "nuget: EasyCore.Pulsar, 8.3.0"
                    
#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 EasyCore.Pulsar@8.3.0
                    
#: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=EasyCore.Pulsar&version=8.3.0
                    
Install as a Cake Addin
#tool nuget:?package=EasyCore.Pulsar&version=8.3.0
                    
Install as a Cake Tool

⚑ EasyCore.Pulsar

EasyCore.Pulsar is an Apache Pulsar infrastructure client for .NET 8. Built on Pulsar.Client, it provides DI registration, connect, topic publish/subscribe, and AcknowledgeAsync. It is not tied to IEvent / EventBus β€” use it standalone, or via the EasyCore.EventBus.Pulsar adapter.

.NET C# Pulsar License Version


🌍 Language


πŸ“š Table of Contents


1. 🎯 Positioning

Scenario Fit?
Byte-level publish/subscribe on Pulsar topics βœ…
Properties and MessageId acknowledgment βœ…
TLS / authentication client options βœ…
Unified IEvent + handler discovery (EDA) ❌ β†’ use EasyCore.EventBus.Pulsar
In-process local events ❌ β†’ use EasyCore.EventBus local bus

1.1 Design Principles

Principle Meaning
Infrastructure layer ServiceUrl, topic prefix, TLS, and raw bytes
Standalone No dependency on the EasyCore.EventBus core package
Adapter-friendly The EventBus Pulsar adapter reuses this client

2. Relation to EventBus

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  App code (any payload)     β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
               β”‚ IPulsarClient
               β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  EasyCore.Pulsar (this)     β”‚  ← infrastructure client
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
               β”‚ Pulsar.Client
               β–Ό
          Pulsar Cluster

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ EasyCore.EventBus.Pulsar    β”‚  ← adapter: IEvent / Handler
β”‚   └── uses this client      β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
Package Role
EasyCore.Pulsar Generic Pulsar client (this package)
EasyCore.EventBus.Pulsar Maps EventBus IEvent onto Pulsar

3. βš™ Requirements

Item Requirement
.NET 8.0+
Dependency Pulsar.Client 3.12.x (brought by this package)
Broker Reachable Pulsar service URL (e.g. pulsar://localhost:6650)

4. πŸ“₯ Installation

dotnet add package EasyCore.Pulsar

5. ⚑ Quick Start

5️⃣.1️⃣ Register DI

using EasyCore.Pulsar;

builder.Services.AddEasyCorePulsar(o =>
{
    o.ServiceUrl = "pulsar://localhost:6650";
    o.TopicPrefix = "persistent://public/default/";
    o.AppName = "MyApp";
    // TLS / auth as needed:
    // o.UseTls = true;
    // o.TlsAllowInsecureConnection = false;
});

5️⃣.2️⃣ Publish

public sealed class InvoicePublisher
{
    private readonly IPulsarClient _client;

    public InvoicePublisher(IPulsarClient client) => _client = client;

    public async Task PublishAsync(string invoiceId, CancellationToken ct = default)
    {
        await _client.ConnectAsync(ct);

        var body = Encoding.UTF8.GetBytes($$"""{"invoiceId":"{{invoiceId}}"}""");
        var properties = new Dictionary<string, string>
        {
            ["EventType"] = "InvoiceCreated"
        };

        // Relative topic names are prefixed with TopicPrefix
        await _client.PublishAsync(
            topic: "invoice.created",
            body: body,
            properties: properties,
            cancellationToken: ct);
    }
}

5️⃣.3️⃣ Subscribe and Acknowledge

public sealed class InvoiceConsumer : BackgroundService
{
    private readonly IPulsarClient _client;

    public InvoiceConsumer(IPulsarClient client) => _client = client;

    protected override async Task ExecuteAsync(CancellationToken stoppingToken)
    {
        await _client.ConnectAsync(stoppingToken);

        await _client.SubscribeAsync(
            topics: new[] { "invoice.created" },
            handler: async (msg, ct) =>
            {
                var json = Encoding.UTF8.GetString(msg.Body.Span);
                // handle business…

                await _client.AcknowledgeAsync(msg.MessageId, ct);
            },
            cancellationToken: stoppingToken);
    }
}

PulsarDeliveredMessage fields: Topic, Body, Properties, MessageId.


6. 🧩 API Overview

Member Description
AddEasyCorePulsar(Action<PulsarOptions>) DI: Options and IPulsarClient
ConnectAsync Connect to ServiceUrl and build the native client
PublishAsync(topic, body, properties?) Publish; relative topics get TopicPrefix
SubscribeAsync(topics, handler) Subscribe and start a background consume loop
AcknowledgeAsync(messageId) Acknowledge by Pulsar MessageId

IPulsarClient implements IAsyncDisposable β€” dispose on shutdown.


7. Options (PulsarOptions)

Property Type Default Description
ServiceUrl string pulsar://localhost:6650 Pulsar service URL
EnableClientLog bool false Enable native client logging
UseTls bool library default Enable TLS
TlsHostnameVerificationEnable bool library default TLS hostname verification
TlsAllowInsecureConnection bool library default Allow insecure TLS
TlsTrustCertificate X509Certificate2 library default Trust certificate
Authentication Authentication library default Pulsar auth plugin/config
TlsProtocols SslProtocols library default Allowed TLS protocols
TopicPrefix string persistent://public/default/ Prefix for relative topic names
AppName string? null Subscription/consumer naming; entry assembly when null

TLS / Authentication defaults come from PulsarClientConfiguration.Default.


8. ❓ FAQ

Q: This package vs EasyCore.EventBus.Pulsar?
A: Use the EventBus adapter for IEvent, handlers, and retries. Use this package for raw topic I/O.

Q: Must topics be fully qualified?
A: Relative names are fine (prefixed with TopicPrefix), or use full persistent://tenant/ns/topic.

Q: Must I call ConnectAsync first?
A: Yes β€” connect before publish or subscribe so the native client is built.

Q: How do I enable TLS?
A: Set UseTls = true and configure certificates, hostname verification, and Authentication as needed.


9. πŸ“„ License

MIT β€” see the repository LICENSE, or the NuGet package metadata.


🀝 Contributing

Issues and PRs are welcome. After changing this package, verify EasyCore.EventBus.Pulsar and related demos.

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 EasyCore.Pulsar:

Package Downloads
EasyCore.EventBus.Pulsar

.NET Core EventBus distributed transport based on Pulsar.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
8.3.1 124 8/4/2026
8.3.0 121 7/21/2026
8.0.0 133 7/18/2026