Repository navigation
fix(binding-mqtt): complete in-flight deliveries when unsubscribing - #3113
Merged
jfallows merged 21 commits intoNov 17, 2026
Conversation
This was referenced Nov 11, 2026
jfallows
force-pushed
the
feature/mqtt-shared-subscriptions-5-mqtt-unsubscribe-drain
branch
from
November 12, 2026 21:28
298bad7 to
4659779
Compare
jfallows
force-pushed
the
feature/mqtt-shared-subscriptions-5-mqtt-unsubscribe-drain
branch
from
November 12, 2026 21:45
4659779 to
0a76d6f
Compare
After the last filter of a subscribe stream is unsubscribed, the application may reset or abort the stream. The client connection must stay alive and keep answering pings. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoVCzGPCAFKe3smSge2
…ave the connection alive A reset of a subscribe stream that no longer carries filters is cleanup, not a reason to disconnect the client. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoVCzGPCAFKe3smSge2
A subscribe stream that no longer carries filters has nothing to reject. When the application resets it, release the stream without disconnecting the client, as only a stream that still carries filters can be rejected. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoVCzGPCAFKe3smSge2
… 1 or 2 Unsubscribing a shared subscription acknowledges with success and ends its stream even when the application state granted the subscription a QoS of 1 or 2. Cover the network, application and upstream sides. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoVCzGPCAFKe3smSge2
…on to succeed and end its stream Run the scenarios through the server binding and through the server to client pipeline. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoVCzGPCAFKe3smSge2
…cription was granted a qos The reason code of a subscription records the QoS it was granted, which is not a valid unsubscribe reason code and does not mean the unsubscribe failed. Acknowledge such an unsubscribe with success and remove the subscription from its stream, ending a shared subscription stream that carries no other filter. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoVCzGPCAFKe3smSge2
…dgement A subscribe stream keeps carrying acknowledgements for messages already sent to the client after the last filter is unsubscribed, and only then ends. The application receives a flush with no filters when the last filter is removed, a new message after the unsubscribe is not delivered, a message in progress is completed, a disconnect ends the stream at once, a reset is cleanup and the same filter can be subscribed again meanwhile. Cover shared subscriptions, and a non-shared stream that keeps acknowledging while it carries no filters, for MQTT 5 and MQTT 3.1.1. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoVCzGPCAFKe3smSge2
…acknowledgement Run the scenarios through the server binding, and the shared subscription acknowledgement scenarios through the server to client pipeline. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoVCzGPCAFKe3smSge2
…carries no filters When the application ends a subscribe stream after telling it that no filters remain, there is nothing left to unsubscribe, and an UNSUBSCRIBE packet without topic filters is malformed. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoVCzGPCAFKe3smSge2
…ending an unsubscribed stream When the last filter of a shared subscription stream is unsubscribed, keep the stream open while messages already sent to the client are still awaiting their PUBACK, PUBREC or PUBCOMP, so the acknowledgements reach the application, and end it once none remain. The application is told by a flush without filters. A message in progress is completed, a message that starts afterwards is not delivered and is not acknowledged to the application, and a message whose subscription identifiers belong only to removed filters is not delivered. A disconnect or reset ends the stream at once. A new subscription of the same filter opens a new stream while the previous one drains. The subscribe stream decodes data in states, as the connection decodes packets: a new message, a delivered message in progress and an ignored message in progress. Acknowledgements for a packet id that no stream awaits are ignored. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoVCzGPCAFKe3smSge2
…le unsubscribing A stream that keeps other filters does not deliver a message whose subscription identifier belongs to a removed filter, and a non-shared stream carrying a message awaiting acknowledgement accepts the same filter again. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoVCzGPCAFKe3smSge2
Run the scenarios through the server binding. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoVCzGPCAFKe3smSge2
Cover two consecutive SUBSCRIBE packets with a message delivered on the first, then the second, then the first again, for shared then shared, shared then non-shared, non-shared then shared and non-shared then non-shared at QoS 1 and 2, and a shared subscription resubscribed at a different QoS. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoVCzGPCAFKe3smSge2
…gh the pipeline Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoVCzGPCAFKe3smSge2
…her than granted qos A subscription acknowledged with a granted QoS reports that QoS as its reason code, while the same subscription carried in a later state may report success, so equality on the raw reason code made subscriptions that had not changed look added and removed. A later subscribe then reopened already established streams and its subscribe acknowledgement never completed. Treat every granted QoS as success when comparing, keeping failure codes distinct so a subscription whose removal was declined still differs from its previous state. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoVCzGPCAFKe3smSge2
…m change A publish carrying a subscription identifier that the subscribe stream did not yet hold was left undecoded, and nothing resumed decoding once the stream received the filters that include it, so a resubscribe at a different QoS never delivered its first message. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoVCzGPCAFKe3smSge2
…e delivering its publish A publish for a shared subscription whose subscribe stream had not yet begun fell back to the non-shared stream of the same QoS and was delivered to the wrong subscription. Only fall back to the non-shared stream when the publish does not belong to a shared subscription, so decoding waits for the shared stream to begin. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoVCzGPCAFKe3smSge2
Cover unsubscribing a shared subscription and then disconnecting, disconnecting with a shared subscription still established, a shared subscription resubscribed at a different QoS and then unsubscribed, and a subscribe stream ended while its shared subscription is still established. The disconnect that follows each unsubscribe exposes any further unsubscribe sent for the same filter. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoVCzGPCAFKe3smSge2
…tion Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoVCzGPCAFKe3smSge2
…ters still subscribed A subscribe stream that ended after its filters were already removed through the session state unsubscribed them a second time, sending a further UNSUBSCRIBE for each filter. Unsubscribe only the filters the session still holds, and release them from the session as they are unsubscribed. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoVCzGPCAFKe3smSge2
…knowledgement and delivery behavior Convert the scenarios to the version-aware session state builder, add an MQTT 3.1.1 variant of the in-flight qos 1 application script, and write the unsubscribe acknowledgement after the remaining fragments of a publish that is already in progress. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoWETrA5Cn7uqKAtsMH
jfallows
force-pushed
the
feature/mqtt-shared-subscriptions-5-mqtt-unsubscribe-drain
branch
from
November 17, 2026 07:13
0a76d6f to
f250e94
Compare
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.
Description
UNSUBSCRIBE in
binding-mqttstops new matching messages and lets the subscribe stream drain: the stream ENDs only after in-flight QoS 1 and 2 acknowledgements complete (MQTT 5.0 3.10.4-2 and 3.10.4-3). For a shared subscription this means a message already delivered to the client is acknowledged to the application before the subscription ends, rather than being dropped or redelivered to another member.Part of #1801
Behavior
Stack
This is one layer of a stack of PRs for #1801. Each PR contains only the commits since the previous layer; this PR is based on the previous layer's branch.
binding-kafka: share group streamdevelopbinding-mqtt: shared subscriptions, server and clientbinding-mqtt-kafka: shared subscriptions for QoS 0 and 1binding-mqtt: SUBACK after application streams beginbinding-mqtt: complete in-flight deliveries when unsubscribingbinding-mqtt-kafka: QoS 2 claim tickets (with engine test store assertions)binding-mqtt-kafka: epoch registry for the lifecycle of a shared subscriptionmqtt.kafka.proxyexample (top of the stack)Documentation: aklivity/aklivity-docs#181 (merge after the stack).
Test evidence
Run on this branch tip (checkstyle and license checks run in the
validatephase of each build):./mvnw clean install -DskipTests -pl <modules> -am -Dmaven.build.cache.enabled=false: OK./mvnw clean verify -pl specs/binding-mqtt.spec,runtime/binding-mqtt,specs/binding-mqtt-kafka.spec,runtime/binding-mqtt-kafka -Dmaven.build.cache.enabled=false: OK (unit tests / ITs, 0 failures)specs/binding-mqtt.spec: 96 / 601specs/binding-mqtt-kafka.spec: 32 / 263runtime/binding-mqtt: 63 / 482runtime/binding-mqtt-kafka: 29 / 152Notes for reviewers
🤖 Generated with Claude Code
https://claude.ai/code/session_01SiHVoVCzGPCAFKe3smSge2