FluxFlow.Components.Mqtt 2.0.0

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

FluxFlow.Components.Mqtt

MQTT component package for FluxFlow.

This package keeps protocol-specific nodes outside FluxFlow.Engine while preserving the same runtime registration model.

Nodes

Node type Shape Purpose
mqtt.connection resource Owns the MQTT client lifecycle (profile + reconnect policy). Publish and subscribe nodes reference it by name.
mqtt.publish Input → Result Publishes MqttPublishRequest values through a borrowed connection.
mqtt.subscribe source → Output Emits MqttReceivedMessage values from a borrowed connection subscription.

The package does not include a concrete network client. Applications provide an adapter through RegisterMqttComponents.

var registry = new RuntimeNodeFactoryRegistry()
    .RegisterMqttComponents((profile, cancellationToken) =>
        ValueTask.FromResult<IMqttClientAdapter>(
            new AppMqttClientAdapter(profile)));

Options are static node settings. Requests and messages are per-item data.

Connection resource

The mqtt.connection node owns the client. It is a resource: mqtt.publish and mqtt.subscribe do not open their own clients, they borrow the established adapter from a connection by name. The connection carries the broker profile and an optional reconnect policy.

{
  "type": "mqtt.connection",
  "name": "broker",
  "profile": {
    "host": "broker.internal.example",
    "port": 1883,
    "clientId": "fluxflow",
    "useTls": false
  },
  "reconnect": {
    "enabled": true,
    "maxAttempts": 5,
    "initialDelayMilliseconds": 100,
    "maxDelayMilliseconds": 5000,
    "backoffMultiplier": 2,
    "useJitter": true
  }
}

reconnect values are advisory. The package validates them and passes them to the adapter factory through MqttClientFactoryContext.Reconnect. The adapter still owns connection state, retry loops, shared client behavior, and broker-specific recovery.

mqtt.publish and mqtt.subscribe require a connectionName that names an mqtt.connection resource. The reference is mandatory; there is no inline broker configuration on publish or subscribe.

{
  "type": "mqtt.publish",
  "name": "publisher",
  "connectionName": "broker",
  "defaultTopic": "devices/state"
}
{
  "type": "mqtt.subscribe",
  "name": "subscriber",
  "connectionName": "broker",
  "topicFilter": "devices/+/state"
}

Connecting (host-driven)

Connecting is an explicit host decision: there is no auto-connect or lazy connect. StartAsync on the connection is a no-op. The host establishes and tears down the client through IMqttConnectionHandle:

await connection.ConnectAsync(cancellationToken);
// ... run the graph ...
await connection.DisconnectAsync(cancellationToken);

ConnectAsync is idempotent (a no-op when already connected) and single-flight (a concurrent call awaits the in-flight connect). Publish and subscribe borrow the established adapter and never connect or dispose it; a borrow only succeeds while the connection is Connected.

mqtt.publish bounds each adapter publish with publishTimeoutMilliseconds (default 30000). A publish that exceeds the timeout is reported as a per-message error and the node continues with later requests, so a hung adapter cannot wedge the node.

Return MqttClientLease.Owned(adapter) from the factory when the connection should dispose the adapter. Return MqttClientLease.Shared(adapter) when the host owns a shared client lifetime.

Subscriptions return IMqttSubscription; once SubscribeAsync returns, startup is considered successful. Each subscription should expose an independent message stream so shared clients can safely serve multiple nodes.

Runtime Timing

Use MqttComponentOptions.UseClock(TimeProvider) when tests or hosts need deterministic package-owned timestamps. The package uses System.TimeProvider; there is no bespoke MQTT clock interface.

var registry = new RuntimeNodeFactoryRegistry()
    .RegisterMqttComponents(options => options
        .UseClientFactory(factory)
        .UseClock(TimeProvider.System));

mqtt.publish uses the configured clock for MqttPublishResult.Timestamp. MQTT publish, subscribe, and connection health events also use that clock for their FlowEvent.Timestamp values.

Incoming MqttReceivedMessage.Timestamp values stay adapter-owned because they represent when the adapter observed the broker message. Adapter-provided MqttClientHealthEvent.Timestamp values also stay adapter-owned, while the emitted workflow event timestamp uses the configured package clock.

Adapter Health

Adapters that also implement IMqttClientHealthSource can expose connection health transitions. mqtt.publish and mqtt.subscribe forward those values as diagnostics and events named mqtt.connection.healthChanged.

The package does not own reconnect policy. Adapters decide how to connect, reconnect, and report state.

Topic validation

Use MqttTopicValidator.ValidatePublishTopic and MqttTopicValidator.ValidateSubscriptionFilter when projecting host settings or building requests.

Publish topics must be present and cannot contain MQTT wildcards. Subscription filters may use + as a complete level and # only as the final complete level. Both helpers also reject null characters and oversized encoded topics.

Design Metadata

This package exposes a package-owned IComponentDesignMetadataProvider for its node types. Hosts can compose it through ComponentDesignMetadataCatalog to populate palettes, editors, validation views, and documentation without duplicating package descriptors.

Composition Guidance

Use this package as one part of a host-composed graph. See Component Composition for recommended host boundaries, package boundaries, and extraction timing.

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 (3)

Showing the top 3 NuGet packages that depend on FluxFlow.Components.Mqtt:

Package Downloads
FluxFlow.Components.Mqtt.PulseMqtt

Concrete MQTT transport adapter for FluxFlow. Maps resolved client configuration, exact message bytes, subscriptions, and broker acknowledgements while the provider-neutral MQTT core owns client policy and workflow behavior.

FluxFlow.Components.Mqtt.MqttNet

Concrete MQTT transport adapter for FluxFlow. Maps resolved client configuration, exact message bytes, subscriptions, and broker acknowledgements while the provider-neutral MQTT core owns client policy and workflow behavior.

FluxFlow.Components.Mqtt.Composition

Canonical FluxFlow Composition resources and nodes for provider-neutral MQTT client control, publication, subscriptions, and client events.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
8.0.0-rc.1 115 9/5/2026
7.1.0 195 8/9/2026
7.0.0 209 8/3/2026
4.1.4 178 7/3/2026
4.1.3 238 7/2/2026
4.0.0 183 6/20/2026
3.0.0 128 6/19/2026
2.0.0 147 6/18/2026
1.2.1 126 6/15/2026
1.2.0 428 6/12/2026
1.1.0 127 6/5/2026
1.0.0 126 6/4/2026
0.5.0-alpha.1 252 6/3/2026
0.4.0-alpha.1 80 6/2/2026
0.3.0-alpha.1 78 6/2/2026
0.2.2-alpha.1 84 6/2/2026
0.2.1-alpha.1 135 5/31/2026
0.2.0-alpha.1 83 5/31/2026
0.1.0-alpha.1 83 5/31/2026

2.0 preview: the node's static Create(RuntimeNodeFactoryContext …) factory moves into a dedicated internal *NodeFactory class, removing the public static Create from the node type (breaking). Node registration, options, ports, JSON shape, and runtime behavior are unchanged. Replaces the bespoke IMqttClock abstraction with System.TimeProvider (UseClock now takes a TimeProvider; the old clock interface/implementation are removed). Introduces a separate mqtt.connection resource component that owns the connection profile and reconnect policy; mqtt.publish/mqtt.subscribe now reference it by required connectionName and no longer carry connection/reconnect config. For now the connection holds configuration only — no client is established, so publish/subscribe report a not-connected result until a later connect step. Adds an explicit, host-driven connect lifecycle: mqtt.connection now exposes ConnectAsync/DisconnectAsync (plus a connection State and a lock-free TryGetAdapter), owning the single client lease and health monitor; mqtt.publish/mqtt.subscribe borrow the established adapter when connected (subscribe (re)subscribes on connect, deduped per connection epoch) and report not-connected otherwise, never connecting or disposing. No auto-connect.