Skip to content

Feature: add MQTT module - #157

Merged
KnibbsyMan merged 11 commits into
elsa-workflows:mainfrom
Namoshek:feature/mqtt
Jul 14, 2026
Merged

KnibbsyMan merged 11 commits into
elsa-workflows:mainfrom
Namoshek:feature/mqtt

Conversation

@Namoshek

Copy link
Copy Markdown
Contributor

This pull request introduces a new MQTT module to the solution, adding the ability to send and receive MQTT messages within workflows. The changes include new activities for publishing and subscribing to MQTT messages, integration with the workflow runtime, and supporting infrastructure such as connection management and subscription tracking. The solution and project files are updated to include the new module and its unit tests.

MQTT Module Integration

  • Added the new Elsa.Mqtt module and Elsa.Mqtt.UnitTests to the solution, including all necessary project and solution references. (Elsa.Extensions.sln, Directory.Packages.props, Elsa.Mqtt.csproj) [1] [2] [3] [4] [5]

MQTT Activities

  • Introduced the MqttMessageReceived trigger activity, which executes workflows when a message is received on configured MQTT topics. (MqttMessageReceived.cs)
  • Added the PublishMqttMessage activity, enabling workflows to publish messages to MQTT topics with configurable QoS and retain options. (PublishMqttMessage.cs)

MQTT Infrastructure and Services

  • Implemented interfaces and services for managing MQTT connections and publishing messages, including IMqttConnection, IMqttConnectionFactory, and related service registrations. (IMqttConnection.cs, IMqttConnectionFactory.cs, MqttFeature.cs, ModuleExtensions.cs) [1] [2] [3] [4]
  • Added handlers to trigger workflows and update MQTT subscriptions in response to workflow and bookmark lifecycle events. (TriggerMqttWorkflows.cs, UpdateMqttSubscriptions.cs) [1] [2]

Supporting Models and Utilities

  • Introduced models for MQTT messages and bookmark bindings, and utility classes for topic matching. (MqttBookmarkBinding.cs, other supporting files)

These changes collectively enable MQTT-based event-driven workflows, allowing Elsa workflows to interact with IoT and messaging systems using MQTT. The overall implementation is very similar to the Kafka module since subscriptions work likewise.

@greptile-apps

greptile-apps Bot commented Jun 12, 2026

Copy link
Copy Markdown

PR author is not in the allowed authors list.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request adds a new Elsa.Mqtt module to the extensions solution, enabling Elsa workflows to publish MQTT messages and to trigger/resume workflows when MQTT messages are received. It includes runtime integration for subscription management plus a new unit test project for the MQTT module.

Changes:

  • Added MQTT activities (MqttMessageReceived, PublishMqttMessage) and supporting UI hints.
  • Implemented MQTT infrastructure (connection factory/proxy, subscriber + subscriber manager, lifecycle handlers, startup task).
  • Integrated the module into the workbench apps and added unit tests + solution/package updates.

Reviewed changes

Copilot reviewed 39 out of 39 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
test/modules/mqtt/Elsa.Mqtt.UnitTests/Utilities/MqttTopicMatcherTests.cs Unit tests for MQTT topic filter matching behavior.
test/modules/mqtt/Elsa.Mqtt.UnitTests/Services/MqttSubscriberTests.cs Unit tests for subscriber binding/unbinding and broker subscription calls.
test/modules/mqtt/Elsa.Mqtt.UnitTests/Services/MqttConnectionFactoryTests.cs Unit tests for resolving connection options and error messaging.
test/modules/mqtt/Elsa.Mqtt.UnitTests/Options/MqttConnectionOptionsTests.cs Unit tests for MQTT client options generation (IDs, credentials, TLS).
test/modules/mqtt/Elsa.Mqtt.UnitTests/Handlers/TriggerMqttWorkflowsTests.cs Unit tests for routing MQTT messages to triggers/bookmarks.
test/modules/mqtt/Elsa.Mqtt.UnitTests/Elsa.Mqtt.UnitTests.csproj Adds the MQTT module reference for the new test project.
src/workbench/Elsa.ServerAndStudio.Web/Program.cs Enables MQTT module in the combined server+studio workbench app.
src/workbench/Elsa.ServerAndStudio.Web/Elsa.ServerAndStudio.Web.csproj References Elsa.Mqtt from the workbench app.
src/workbench/Elsa.Server.Web/Program.cs Enables MQTT module in the server workbench app.
src/workbench/Elsa.Server.Web/Elsa.Server.Web.csproj References Elsa.Mqtt from the workbench app.
src/modules/mqtt/Elsa.Mqtt/Utilities/MqttTopicMatcher.cs Adds MQTT topic filter matching helper.
src/modules/mqtt/Elsa.Mqtt/UIHints/MqttQosLevelDropdownOptionsProvider.cs Adds QoS dropdown options provider for Studio UI.
src/modules/mqtt/Elsa.Mqtt/UIHints/MqttConnectionDropdownOptionsProvider.cs Adds connection-name dropdown options provider for Studio UI.
src/modules/mqtt/Elsa.Mqtt/Tasks/StartMqttSubscriptionsTask.cs Startup/shutdown task for initializing and stopping subscriptions.
src/modules/mqtt/Elsa.Mqtt/Stimuli/MqttMessageReceivedStimulus.cs Defines the stored stimulus payload for triggers/bookmarks.
src/modules/mqtt/Elsa.Mqtt/Services/MqttSubscriberManager.cs Manages subscribers per connection and syncs bindings from stores.
src/modules/mqtt/Elsa.Mqtt/Services/MqttSubscriber.cs Maintains bindings, subscribes/unsubscribes topics, dispatches notifications.
src/modules/mqtt/Elsa.Mqtt/Services/MqttConnectionProxy.cs Wraps MQTTnet client publishing behind IMqttConnection.
src/modules/mqtt/Elsa.Mqtt/Services/MqttConnectionFactory.cs Creates/caches MQTT connections from configured options.
src/modules/mqtt/Elsa.Mqtt/Services/IMqttSubscriberManager.cs Defines subscriber manager contract.
src/modules/mqtt/Elsa.Mqtt/README.md Module documentation: install/configuration/usage notes.
src/modules/mqtt/Elsa.Mqtt/Options/MqttOptions.cs Module options for connections and reconnect behavior.
src/modules/mqtt/Elsa.Mqtt/Options/MqttConnectionOptions.cs Builder for MQTTnet client options (host/port/creds/TLS).
src/modules/mqtt/Elsa.Mqtt/Notifications/MqttMessageReceivedNotification.cs Notification published on MQTT message receipt.
src/modules/mqtt/Elsa.Mqtt/Models/MqttTriggerBinding.cs Model binding triggers to MQTT stimuli.
src/modules/mqtt/Elsa.Mqtt/Models/MqttMessage.cs Transport message model (topic + payload).
src/modules/mqtt/Elsa.Mqtt/Models/MqttBookmarkBinding.cs Model binding bookmarks to MQTT stimuli.
src/modules/mqtt/Elsa.Mqtt/Handlers/UpdateMqttSubscriptions.cs Keeps subscriptions in sync with trigger/bookmark lifecycle events.
src/modules/mqtt/Elsa.Mqtt/Handlers/TriggerMqttWorkflows.cs Routes received MQTT messages to trigger invocations/bookmark resumes.
src/modules/mqtt/Elsa.Mqtt/FodyWeavers.xml Adds Fody weaver configuration file for the module.
src/modules/mqtt/Elsa.Mqtt/Features/MqttFeature.cs Registers MQTT services/handlers/activities/background tasks.
src/modules/mqtt/Elsa.Mqtt/Extensions/ModuleExtensions.cs Adds UseMqtt extension for module installation.
src/modules/mqtt/Elsa.Mqtt/Elsa.Mqtt.csproj New module project definition and dependencies.
src/modules/mqtt/Elsa.Mqtt/Contracts/IMqttConnectionFactory.cs Contract for creating MQTT connections.
src/modules/mqtt/Elsa.Mqtt/Contracts/IMqttConnection.cs Contract for publishing via MQTT.
src/modules/mqtt/Elsa.Mqtt/Activities/PublishMqttMessage.cs New workflow activity to publish MQTT messages.
src/modules/mqtt/Elsa.Mqtt/Activities/MqttMessageReceived.cs New trigger activity for receiving MQTT messages.
Elsa.Extensions.sln Adds MQTT module + unit test projects to the solution.
Directory.Packages.props Adds a central package version for MQTTnet.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/modules/mqtt/Elsa.Mqtt/Activities/PublishMqttMessage.cs Outdated
Comment thread src/modules/mqtt/Elsa.Mqtt/UIHints/MqttConnectionDropdownOptionsProvider.cs Outdated
Comment thread src/modules/mqtt/Elsa.Mqtt/Services/MqttConnectionFactory.cs Outdated
Comment thread src/modules/mqtt/Elsa.Mqtt/Services/MqttConnectionFactory.cs Outdated
Comment thread src/modules/mqtt/Elsa.Mqtt/Services/MqttConnectionFactory.cs Outdated
Comment thread src/workbench/Elsa.Server.Web/Program.cs
Comment thread src/workbench/Elsa.ServerAndStudio.Web/Program.cs
Comment thread src/modules/mqtt/Elsa.Mqtt/Activities/PublishMqttMessage.cs Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 41 out of 41 changed files in this pull request and generated 4 comments.

Comment thread src/modules/mqtt/Elsa.Mqtt/Options/MqttConnectionOptions.cs Outdated
Comment thread src/modules/mqtt/Elsa.Mqtt/Services/MqttClientFactory.cs Outdated
Comment thread src/modules/mqtt/Elsa.Mqtt/Services/MqttClientFactory.cs Outdated
Comment thread test/modules/mqtt/Elsa.Mqtt.UnitTests/Services/MqttClientFactoryTests.cs Outdated
@KnibbsyMan

Copy link
Copy Markdown
Member

Hi @Namoshek,

Another great PR! Apply / dismiss these last comments as you see fit and I'll get this merged!

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@Namoshek

Copy link
Copy Markdown
Contributor Author

Thanks for the reviews, should be good to go now.

Please also let me know what you think about #129 and if its worth to pursue. 👍

@KnibbsyMan
KnibbsyMan merged commit 4b672e3 into elsa-workflows:main Jul 14, 2026
3 checks passed
@Namoshek
Namoshek deleted the feature/mqtt branch July 15, 2026 04:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants