Feature: add MQTT module - #157
Conversation
|
PR author is not in the allowed authors list. |
There was a problem hiding this comment.
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.
|
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>
|
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. 👍 |
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
Elsa.Mqttmodule andElsa.Mqtt.UnitTeststo 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
MqttMessageReceivedtrigger activity, which executes workflows when a message is received on configured MQTT topics. (MqttMessageReceived.cs)PublishMqttMessageactivity, enabling workflows to publish messages to MQTT topics with configurable QoS and retain options. (PublishMqttMessage.cs)MQTT Infrastructure and Services
IMqttConnection,IMqttConnectionFactory, and related service registrations. (IMqttConnection.cs,IMqttConnectionFactory.cs,MqttFeature.cs,ModuleExtensions.cs) [1] [2] [3] [4]TriggerMqttWorkflows.cs,UpdateMqttSubscriptions.cs) [1] [2]Supporting Models and Utilities
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.