FluxFlow.Components.Mqtt 4.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 4.0.0
                    
NuGet\Install-Package FluxFlow.Components.Mqtt -Version 4.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="4.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="4.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 4.0.0
                    
#r "nuget: FluxFlow.Components.Mqtt, 4.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@4.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=4.0.0
                    
Install as a Cake Addin
#tool nuget:?package=FluxFlow.Components.Mqtt&version=4.0.0
                    
Install as a Cake Tool

FluxFlow.Components.Mqtt

Standalone MQTT nodes for FluxFlow, built on the FluxFlow.Nodes kit. No engine, registry, runtime, or concrete network client is required: provide a publisher or trigger-source implementation in the host, new the nodes, LinkTo their ports, and run.

Applications supply small interfaces that can be implemented over any MQTT client library:

  • IMqttPublisher publishes MqttPublishRequest values.
  • IMqttTriggerSource opens IMqttSubscription streams for trigger nodes.
  • IMqttClientHealthSource exposes optional client-health transitions.

One concrete object may implement any combination of these interfaces. The MQTT nodes depend only on the role they actually need.

Nodes

Node Shape Purpose
MqttPublishNode FlowNode<MqttPublishRequest, MqttPublishResult> Publishes a request through an injected IMqttPublisher and emits a result carrying the same correlation id.
MqttTriggerNode FlowSource<MqttReceivedMessage> Opens one subscription through an injected IMqttTriggerSource and emits each received message. In request/reply mode it waits for a correlated MqttTriggerResponse.

Publish and trigger are ordinary kit nodes: a bounded Input for publish, broadcast Output, Errors, and Events ports, plus a Responses target on MqttTriggerNode when request/reply acknowledgement is needed. Nodes never create, start, stop, reconnect, or dispose a concrete client. Client-session ownership, connection policy, and reconnect policy belong behind the supplied interfaces.

Contracts

public interface IMqttPublisher
{
    ValueTask PublishAsync(MqttPublishRequest request, CancellationToken cancellationToken = default);
}

public interface IMqttTriggerSource
{
    ValueTask<IMqttSubscription> SubscribeAsync(
        MqttTriggerOptions options,
        CancellationToken cancellationToken = default);
}

public interface IMqttSubscription : IAsyncDisposable
{
    IAsyncEnumerable<IMqttReceivedContext> Messages { get; }
}

public interface IMqttReceivedContext
{
    MqttReceivedMessage Message { get; }
    ValueTask AckAsync(CancellationToken cancellationToken = default);
    ValueTask NackAsync(Exception? error = null, CancellationToken cancellationToken = default);
}

public interface IMqttClientHealthSource
{
    IAsyncEnumerable<MqttClientHealthEvent> Health { get; }
}

Implementations should throw MqttClientUnavailableException when they cannot publish or open a trigger subscription because no client is currently available. Nodes translate that into the package not-connected error codes and keep running.

Publish

var publish = new MqttPublishNode(
    publisher,
    new MqttPublishOptions
    {
        PublishTimeoutMilliseconds = 30_000,
        BoundedCapacity = 128
    });

publish.Output.LinkTo(resultSink);
await publish.Input.SendAsync(FlowMessage.Create(new MqttPublishRequest
{
    Topic = "devices/temperature",
    Payload = payloadBytes,
    QualityOfService = MqttQualityOfService.AtLeastOnce,
    Retain = false,
    Properties = new MqttPublishProperties
    {
        CorrelationId = "abc"
    }
}));

The result carries the inbound FlowMessage correlation id forward. When the publisher reports unavailability, the request reports MqttErrorCodes.PublishNotConnected on Errors and the node continues with later requests. Each publish is bounded by publishTimeoutMilliseconds (default 30000), so a hung implementation cannot wedge the node.

Each MqttPublishRequest carries its publish Topic explicitly. The publish node does not fill a missing topic from static options. Quality of service and retain are also request-owned publish semantics; static publish options only control node runtime behavior such as timeout and bounded input capacity.

MqttPublishRequest.Properties contains MQTT protocol metadata such as MQTT correlation id, response topic, and user properties. Workflow correlation stays on the surrounding FlowMessage.

Trigger

var trigger = new MqttTriggerNode(
    triggerSource,
    new MqttTriggerOptions { TopicFilter = "devices/+/state" });

trigger.Output.LinkTo(messageSink);
await trigger.StartAsync();

The trigger source opens one IMqttSubscription and emits a FlowMessage<MqttReceivedMessage> for each received message, flowing the implementation-supplied correlation id when present. The subscription is disposed when the source stops. Reconnect and resubscribe behavior belongs inside the supplied IMqttTriggerSource or concrete client adapter.

For request/reply handling, configure the trigger and post the graph response back to Responses with the same correlation id:

var trigger = new MqttTriggerNode(
    triggerSource,
    new MqttTriggerOptions
    {
        TopicFilter = "commands/+",
        Mode = MqttTriggerMode.RequestReply,
        Acknowledgement = MqttTriggerAcknowledgement.OnSuccessfulResponse,
        ResponseTimeout = TimeSpan.FromSeconds(30)
    });

trigger.Output.LinkTo(handler);

await trigger.Responses.SendAsync(receivedMessage.With(
    MqttTriggerResponse.Success()));

MqttTriggerAcknowledgement.None leaves ack/nack entirely to the adapter. OnEmit acknowledges after the trigger emits the message to Output. OnSuccessfulResponse is for request/reply mode: success responses call AckAsync; failure responses and timeouts call NackAsync.

Request/reply correlation, duplicate detection, timeout, and pending cleanup use the shared CorrelatedRequestTracker from FluxFlow.Components.RequestReply; MQTT keeps only MQTT-specific subscription and ack/nack policy in the trigger node.

Adapter-Owned Client Session

Broker addresses, credentials, reconnect policy, concrete client lifetime, and MQTT Last Will belong to the supplied implementation or a future adapter package. Last Will is registered during MQTT CONNECT, so it is not part of MqttPublishOptions or MqttTriggerOptions. For graceful offline messages, publish an ordinary MqttPublishRequest.

Client Health

Adapters that also implement IMqttClientHealthSource can expose connection health transitions to hosts, dashboards, or future monitoring nodes. The publish and trigger nodes do not consume health directly.

Incoming MqttReceivedMessage.Timestamp and adapter-provided MqttClientHealthEvent.Timestamp values stay adapter-owned.

Runtime Timing

Pass a TimeProvider to any node when tests or hosts need deterministic package-owned timestamps such as publish result times, node event times, and trigger response timeouts.

Topic Validation

Use MqttTopicValidator.ValidatePublishTopic and MqttTopicValidator.ValidateSubscriptionFilter when projecting host settings or building requests. Publish request 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 reject null characters and oversized encoded topics. MqttPublishNode validates publish request topics before calling IMqttPublisher; MqttTriggerNode validates its static TopicFilter before opening a subscription.

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 194 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

Breaking cleanup of the MQTT component boundary. The core package now exposes only client-library-neutral publish, trigger, health, received-context, and protocol metadata contracts. Publish and trigger nodes no longer own connection handles, factories, profiles, reconnect policy, concrete client creation, or client lifetime. MqttPublishOptions now contains only node runtime settings; publish topic, quality-of-service, retain flag, payload, and MQTT protocol metadata live on MqttPublishRequest. Trigger request/reply uses CorrelatedRequestTracker for pending correlation and timeout mechanics while acknowledgement policy stays MQTT-owned. Concrete client-library integrations are split into separate adapter packages.