Skip to content

63 mqtt connector capacity limitation#64

Merged
lxsaah merged 12 commits intomainfrom
63-mqtt-connector-capacity-limitation
Dec 23, 2025
Merged

63 mqtt connector capacity limitation#64
lxsaah merged 12 commits intomainfrom
63-mqtt-connector-capacity-limitation

Conversation

@lxsaah
Copy link
Contributor

@lxsaah lxsaah commented Dec 23, 2025

Summary

This PR fixes a critical MQTT connector deadlock (Issue #63) and introduces shared demo crates for cross-platform code reuse.

🐛 Bug Fix

MQTT Connector Deadlock with >10 Topics (Issue #63)

Fixed an initialization deadlock when subscribing to more than 10 MQTT topics. The root cause was that rumqttc's internal channel had a hardcoded capacity of 10, causing the subscribe loop to block when topics exceeded channel capacity before the event loop started draining.

Fix:

  1. Spawn-before-subscribe: Event loop is now spawned before subscribing to topics
  2. Dynamic channel capacity: Channel capacity now scales with topic count (topics + 10)
  3. Task yield: Added tokio::task::yield_now().await to ensure proper task scheduling

✨ New Features

Shared Demo Common Crates

  • mqtt-connector-demo-common: Shared types and monitors for MQTT demos
  • knx-connector-demo-common: Shared types and monitors for KNX demos

These crates enable code reuse between Tokio (std) and Embassy (embedded) demos, demonstrating the "write once, run everywhere" pattern for MCU → edge → cloud.

📝 Documentation

  • Added design document 016-M6-record-key-trait.md for RecordKey trait design
  • Updated all crate CHANGELOGs to reflect v0.3.0 release status

🔧 Dependencies

  • Upgraded rumqttc from 0.24 to 0.25
  • Updated embassy and mountain-mqtt submodules
  • Added OpenSSL license allowance in deny.toml

✅ Testing

  • make check passes (fmt, clippy, test, embedded cross-compile, deny)
  • MQTT connector tested with >10 topic subscriptions

Breaking Changes

None for library consumers. Demo examples updated to use key-based API from v0.3.0.


Closes #63

…ogic across MCU, edge, and cloud platforms.

- Implemented common data types (`Temperature`, `TemperatureCommand`) and monitor functions (`temperature_logger`, `command_consumer`).
- Updated `tokio-mqtt-connector-demo` to utilize shared logic for temperature producers and command consumers.
- Enhanced `tokio-knx-connector-demo` to leverage shared types and monitors for temperature and light state handling.
- Improved documentation for clarity on usage and architecture.
- Updated the `produce` and `subscribe` methods in the Database struct to require a record key, enabling key-based routing for multiple records of the same type.
- Removed the optional record key handling in the Producer and Consumer structs, making the record key mandatory for all instances.
- Adjusted the API documentation and examples to reflect the new key-based usage pattern.
- Modified the integration tests and examples to utilize the new key-based producer and consumer methods.
- Cleaned up unused code related to optional key handling and legacy type-based routing.
@lxsaah lxsaah requested a review from Copilot December 23, 2025 18:40
@lxsaah lxsaah self-assigned this Dec 23, 2025
@lxsaah lxsaah linked an issue Dec 23, 2025 that may be closed by this pull request
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a critical MQTT connector deadlock (Issue #63) and introduces shared demo crates for cross-platform code reuse.

Key changes:

  • Fixed MQTT deadlock when subscribing to >10 topics via spawn-before-subscribe pattern and dynamic channel capacity
  • Created mqtt-connector-demo-common and knx-connector-demo-common crates for shared types/monitors
  • Updated all demos to use key-based API from v0.3.0

Reviewed changes

Copilot reviewed 48 out of 49 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
aimdb-mqtt-connector/src/tokio_client.rs Implements deadlock fix: spawn event loop before subscribing, dynamic capacity
examples/mqtt-connector-demo-common/* New shared crate for MQTT types and monitors (Temperature, TemperatureCommand)
examples/knx-connector-demo-common/* New shared crate for KNX types and monitors (TemperatureReading, LightState)
examples/tokio-mqtt-connector-demo/src/main.rs Refactored to use common crate with multiple sensor producers
examples/tokio-knx-connector-demo/src/main.rs Refactored to use common crate with multiple sensor/light monitors
aimdb-mqtt-connector/CHANGELOG.md Documents deadlock fix and demo refactoring
tools/aimdb-mcp/CHANGELOG.md Updated for v0.3.0 release
aimdb-core/CHANGELOG.md Documents key-based API changes and removed legacy methods
Comments suppressed due to low confidence (2)

tools/aimdb-mcp/CHANGELOG.md:1

  • The release date '2025-12-15' is in the future. Based on the knowledge cutoff of January 2025 and current date of December 23, 2025, this should likely be '2024-12-15'.
    tools/aimdb-cli/CHANGELOG.md:1
  • The release date '2025-12-15' is in the future. This should be corrected to '2024-12-15' as December 2025 has not yet occurred.

@lxsaah lxsaah requested a review from Copilot December 23, 2025 18:55
Copy link
Contributor

Copilot AI left a comment

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 48 out of 49 changed files in this pull request and generated no new comments.

Comments suppressed due to low confidence (2)

tools/aimdb-mcp/CHANGELOG.md:1

  • The release date 2025-12-15 is in the future. Based on the system date (December 23, 2025), this should likely be 2024-12-15 instead.
    tools/aimdb-cli/CHANGELOG.md:1
  • The release date 2025-12-15 is in the future. Based on the system date (December 23, 2025), this should likely be 2024-12-15 instead.

@lxsaah lxsaah merged commit 5a9efe3 into main Dec 23, 2025
12 of 13 checks passed
@lxsaah lxsaah deleted the 63-mqtt-connector-capacity-limitation branch December 23, 2025 19:08
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.

MQTT Connector Capacity Limitation

2 participants