CodeChavez.EventBus.MQTT.Abstractions 1.0.0-preview004

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

CodeChavez.EventBus.MQTT

A comprehensive .NET 10 Event Bus library for MQTT messaging that provides simplified connection management, subscription handling, and event publishing capabilities using MQTTnet.

Overview

CodeChavez.EventBus.MQTT is a modular event bus library that simplifies MQTT client operations with built-in logging and configuration management. It provides an abstraction layer over MQTTnet, making it easy to integrate MQTT messaging patterns (pub/sub, event bus) into your .NET applications.

Packages

This project provides two NuGet packages:

  • CodeChavez.EventBus.MQTT.Abstractions (v1.0.0-preview004) - Interfaces and abstractions for MQTT implementations
  • CodeChavez.EventBus.MQTT (v1.0.0-preview004) - Full implementation of the MQTT event bus

Features

  • Simple Connection Management - Easily connect to MQTT brokers with configurable options
  • Subscription Management - Subscribe to MQTT topics with event handling
  • Event Publishing - Publish messages to MQTT topics through the event bus pattern
  • Logging Support - Built-in logging for debugging and monitoring
  • Configuration Options - Flexible configuration through dependency injection
  • Async/Await Support - Fully asynchronous operations
  • Nullable Reference Types - Full nullable reference type support for safer code
  • Implicit Usings - Streamlined using statements for .NET 10

Installation

Add the CodeChavez.EventBus.MQTT NuGet package to your project:

dotnet add package CodeChavez.EventBus.MQTT

Or, if you only need the abstractions:

dotnet add package CodeChavez.EventBus.MQTT.Abstractions

Quick Start

Configuration

First, configure your MQTT options in your dependency injection container:

services.Configure<ConsumerMqttOptions>(configuration.GetSection("MqttConfig"));
services.AddScoped<IEventBusMqttClient, EventBusMqttClient>();

Usage Example

public class MqttService
{
    private readonly IEventBusMqttClient _mqttClient;
    private IMqttClient _client;

    public MqttService(IEventBusMqttClient mqttClient)
    {
        _mqttClient = mqttClient;
    }

    public async Task ConnectAsync()
    {
        // Connect to MQTT broker
        _client = await _mqttClient.ConnectAsync("my-client-id");
    }

    public async Task SubscribeAsync(string topic)
    {
        // Subscribe to a topic
        await _mqttClient.SubscribeAsync(topic);
    }

    public async Task DisconnectAsync()
    {
        // Disconnect from MQTT broker
        if (_client != null)
        {
            await _mqttClient.DisconnectAsync(_client);
        }
    }
}

Configuration Example

Add the following to your appsettings.json:

{
  "MqttConfig": {
    "Host": "mqtt.example.com",
    "Port": 1883,
    "Consumer": {
      "ClientId": "my-mqtt-client",
      "KeepAlivePeriod": 60,
      "CleanSession": true
    }
  }
}

Requirements

  • .NET 10 or higher
  • MQTTnet 5.1.0.1559 or higher

License

MIT

Product Compatible and additional computed target framework versions.
.NET 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.
  • net10.0

    • No dependencies.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on CodeChavez.EventBus.MQTT.Abstractions:

Package Downloads
CodeChavez.EventBus.MQTT

Event Bus MQTT is a wrapper using MQTTNet to connect to MQTT Brokers. This allow for modularity

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0-preview004 38 3/26/2026
1.0.0-preview003 43 3/25/2026
1.0.0-preview002 43 3/17/2026
1.0.0-preview001 39 3/17/2026