SimpleMessageBroker.Client 0.0.5

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

SimpleMessageBroker.Client

C# Client SDK for SimpleMessageBroker — a lightweight single-node message queue middleware.

Features

  • JSON over HTTP — RESTful API communication, easy to integrate and debug
  • byte[] Payload — serialization-agnostic; bring your own serializer
  • DI Integration — one-liner AddMessageQueueClient() registration with IHttpClientFactory connection pooling
  • Exponential Backoff Retry — automatic retry on HTTP 5xx, network timeout, and connection failures (no retry on 4xx)
  • Batch Operations — produce and acknowledge messages in batches
  • Typed Message Handler — IMessageHandler<T> for type-safe message consumption
  • Multi-TFM Support — targets net8.0 and net10.0

Supported Frameworks

TFM Status
net8.0 Compatible
net10.0 Compatible

Dependencies

Package net8.0 net10.0
Microsoft.Extensions.DependencyInjection.Abstractions >= 8.0.2 >= 10.0.11
Microsoft.Extensions.Http >= 8.0.1 >= 10.0.11

Installation

dotnet add package SimpleMessageBroker.Client

Quick Start

1. Register the client

using SimpleMessageBroker.Client.Extensions;

builder.Services.AddMessageQueueClient(options =>
{
    options.BaseAddress = "http://localhost:5000";
    // options.ApiKey = "your-api-key";       // optional
    // options.DefaultTimeout = TimeSpan.FromSeconds(30);
    // options.MaxRetries = 3;
    // options.MaxConnectionsPerServer = 50;
});

2. Produce messages

var client = serviceProvider.GetRequiredService<IMessageQueueClient>();

var payload = JsonSerializer.SerializeToUtf8Bytes(new { OrderId = "123", Amount = 99.99 });

var result = await client.ProduceAsync(
    topic: "orders",
    payload: payload,
    key: "user-123",
    contentType: "application/json",
    headers: new Dictionary<string, string>
    {
        ["source"] = "order-service"
    });

Console.WriteLine($"Message ID: {result.MessageId}, Partition: {result.Partition}");

3. Consume messages

var result = await client.ConsumeAsync(
    topic: "orders",
    consumerGroup: "payment-service",
    consumerId: "payment-instance-1",
    batchSize: 10,
    timeoutSeconds: 30);

foreach (var msg in result.Messages)
{
    // Process the message...
    var order = JsonSerializer.Deserialize<MyOrder>(msg.Payload);

    // Acknowledge after successful processing
    await client.AcknowledgeAsync(msg.Id, "payment-service", "payment-instance-1");
}

4. Batch produce

var messages = new List<ProduceMessage>
{
    new()
    {
        Topic = "orders",
        Payload = JsonSerializer.SerializeToUtf8Bytes(new { OrderId = "001" }),
        Key = "user-001",
        ContentType = "application/json"
    },
    new()
    {
        Topic = "orders",
        Payload = JsonSerializer.SerializeToUtf8Bytes(new { OrderId = "002" }),
        Key = "user-002",
        ContentType = "application/json"
    }
};

var results = await client.ProduceBatchAsync(messages);

API Reference

IMessageQueueClient

Method Description
ProduceAsync(topic, payload, key?, contentType?, headers?, ttlSeconds?) Produce a single message
ProduceBatchAsync(messages) Produce a batch of messages
ConsumeAsync(topic, consumerGroup, consumerId?, batchSize?, timeoutSeconds?) Pull messages from a topic
AcknowledgeAsync(messageId, consumerGroup, consumerId?) Acknowledge a single message
AcknowledgeBatchAsync(messageIds, consumerGroup, consumerId?) Acknowledge a batch of messages
GetQueueDepthAsync(topic, consumerGroup?) Get queue depth for a topic

IMessageHandler<T>

Generic typed message handler for type-safe consumption:

public class OrderHandler : IMessageHandler<OrderPayload>
{
    public Task HandleAsync(OrderPayload message, MessageContext context, CancellationToken ct = default)
    {
        Console.WriteLine($"Processing order {message.OrderId} from partition {context.Partition}");
        return Task.CompletedTask;
    }
}

IPayloadSerializer

Serialization interface — implement your own (SDK does NOT include any built-in serializer):

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

Configuration

MessageQueueClientOptions:

Option Default Description
BaseAddress http://localhost:5000 SimpleMessageBroker server URL
ApiKey null API key for authentication (sent as X-Api-Key header)
DefaultTimeout 30s HTTP request timeout
MaxRetries 3 Maximum retry attempts
InitialBackoffMs 100 Initial retry backoff (ms)
MaxBackoffMs 5000 Maximum retry backoff (ms)
BackoffMultiplier 2.0 Backoff multiplier
MaxConnectionsPerServer 50 HTTP connection pool size

Retry Policy

Built-in exponential backoff retry with the following behavior:

Scenario Behavior
HTTP 4xx No retry — throw immediately
HTTP 5xx Exponential backoff retry
Network timeout Exponential backoff retry
Connection failure Exponential backoff retry

Backoff sequence (default): 100ms → 200ms → 400ms (max 3 retries).

License

MIT

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 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. 
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 SimpleMessageBroker.Client:

Package Downloads
MinGo.Messaging.SimpleMessageBroker

SimpleMessageBroker transport integration for MinGo.Messaging. Uses the SimpleMessageBroker.Client SDK over JSON over HTTP.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.0.5 115 9/5/2026
0.0.4 151 9/5/2026
0.0.3 111 9/5/2026
0.0.2 104 9/5/2026