Repository navigation
fix: MQTT compliance — message delivery, will messages, QoS 2, sessions - #37
Merged
Merged
Conversation
Change queue naming from `mqtt.{client_id}.{topic}` to
`mqtt:{client_id}:{topic}`. Colons cannot appear in MQTT client IDs
or topic names, eliminating ambiguous splits when client IDs or topics
contain dots.
All `let _ = self.vhost.*()` calls now log errors via tracing::warn instead of silently swallowing them. Covers publish, declare_queue, bind_queue, and delete_queue operations.
- Add will: Option<WillMessage> field for last-will-and-testament - Add clean_disconnect flag to distinguish clean vs unexpected disconnect - Add delivery_tasks: HashMap<String, JoinHandle<()>> for per-subscription background delivery tasks - Cancel delivery tasks on unsubscribe and implement Drop to clean up - Make topic_matches_filter public for use in broker
Refactor broker to use shared writer (Arc<tokio::sync::Mutex<W>>) enabling background delivery tasks to write PUBLISH packets to clients. Changes: - AMQP-to-MQTT message delivery: spawn per-subscription task that polls the AMQP queue via shift(), converts to MQTT PUBLISH, writes to client - Will messages: store from CONNECT, publish on unexpected disconnect (not clean DISCONNECT) - Retained messages on subscribe: send matching retained messages as PUBLISH with retain=true when a new subscription is created - QoS 2 completion: PubRel handler responds with PubComp, completing the PUBLISH->PUBREC->PUBREL->PUBCOMP flow - Session persistence: clean_session=false stores session in broker map on disconnect, restores subscriptions on reconnect; clean_session=true removes any existing session - Fix parking_lot::Mutex deadlock: extract lock().remove() result before match to prevent MutexGuard from living across match arms Tests added: - test_message_delivery_round_trip: publish->subscribe delivery via AMQP - test_will_message_delivery: will published on unexpected disconnect - test_qos2_flow: PUBLISH->PUBREC->PUBREL->PUBCOMP round-trip - test_session_restore: clean_session=false restores, true clears - test_retained_messages_on_subscribe: retained messages sent on subscribe
Benchmark Results
🟢 PASSED: No significant regression. Median of 3 runs. Threshold: -10%. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Test plan
Closes #16