Repository navigation
feat(binding-mqtt): acknowledge subscribe after application streams begin - #3112
Merged
jfallows merged 29 commits intoNov 17, 2026
Conversation
This was referenced Nov 11, 2026
jfallows
force-pushed
the
feature/mqtt-shared-subscriptions-4-mqtt-suback-gating
branch
from
November 12, 2026 21:28
34135eb to
3270be7
Compare
jfallows
force-pushed
the
feature/mqtt-shared-subscriptions-4-mqtt-suback-gating
branch
from
November 12, 2026 21:45
3270be7 to
9a3d35f
Compare
… stream begin A subscription is in effect only once its application stream has replied, so SUBACK follows the reply BEGIN of every stream opened for the SUBSCRIBE. Ordering is pinned on the single network connection by interleaving PINGREQ with the held reply BEGIN. A stream reset before its reply BEGIN is reported per filter in the SUBACK instead of disconnecting the client. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoVCzGPCAFKe3smSge2
…n stream begin Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoVCzGPCAFKe3smSge2
…egin SUBACK was sent as soon as the application subscribe streams were opened, before any had replied, so the client could treat the subscription as in effect while the application had not yet established it. The SUBACK now waits for the reply BEGIN of every application stream the SUBSCRIBE opened, tracked per packet id like the other pending subscribe requests. A stream reset before its reply BEGIN yields the reset reason code, or unspecified error, for its filters in the SUBACK and leaves the connection open. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoVCzGPCAFKe3smSge2
The subscribe data extension carries deferred on the INIT frame of a fragmented message, but the builder and matcher could not set or assert it. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoVCzGPCAFKe3smSge2
The mqtt side of the fragmented shared subscription scenarios now asserts deferred on the INIT frame, matching what the kafka side already asserts, and that an expired fragmented record leaves no deferred on the delivered message. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoVCzGPCAFKe3smSge2
…re reply begin A shared subscription must not report its stream as established until the kafka share stream has replied. The kafka share stream is reset before its reply BEGIN and the mqtt client, waiting on a reply BEGIN, must see the reset without a connected stream. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoVCzGPCAFKe3smSge2
An UNSUBSCRIBE received while the SUBACK of the SUBSCRIBE it undoes is still pending is acknowledged after that SUBACK, for one or for one of two filters, in MQTT 3.1.1 and 5. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoVCzGPCAFKe3smSge2
…cknowledgement Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoVCzGPCAFKe3smSge2
…dgement An UNSUBSCRIBE of a filter whose SUBACK is still pending is held in the deferred unsubscribes and released once every pending SUBACK covering its filters has been sent, so UNSUBACK follows SUBACK. Release moves from the first subscribe stream window to the points where a SUBACK completes. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoVCzGPCAFKe3smSge2
When an application stream for a SUBSCRIBE is reset before it begins, the session state sent to the application no longer contains the failed filters, so a reconnect with Clean Start 0 restores only the accepted filters. The existing reject scenarios now read the rewritten state and new reconnect scenarios are added for MQTT 3.1.1 and 5. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoVCzGPCAFKe3smSge2
…n state Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoVCzGPCAFKe3smSge2
A subscribe stream reset before it begins fails its filters in the SUBACK and those filters are removed from the session state sent to the application, the way an UNSUBSCRIBE removes them, so they are not restored when the client reconnects with Clean Start 0. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoVCzGPCAFKe3smSge2
…rejected A SUBSCRIBE opening exactly-once and at-least-once filters on one route has its exactly-once stream reset before it begins. The SUBACK fails that filter and grants the other, the surviving streams keep delivering and acknowledging at-least-once messages, and an UNSUBSCRIBE and a DISCONNECT still reach them. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoVCzGPCAFKe3smSge2
…am is rejected Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoVCzGPCAFKe3smSge2
Closing a non-shared subscribe stream removed the whole per-route map of streams, orphaning the streams of the other QoS levels, so unsubscribe and disconnect could no longer reach them. Only the closing stream is removed, and the route entry only once it holds no streams. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoVCzGPCAFKe3smSge2
A subscribe stream reset before it begins fails only filters of pending SUBACKs. A stream that also carries restored filters ends the connection, two back-to-back SUBSCRIBEs sharing one unreplied stream each get failure codes in order, and a rejected stream of the new SUBSCRIBE leaves restored filters on their own streams untouched, in MQTT 3.1.1 and 5. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoVCzGPCAFKe3smSge2
Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoVCzGPCAFKe3smSge2
The subscriptions restored for a reconnect with Clean Start 0 were not recorded as the session's current state, so the next SUBSCRIBE wrote a session state without them and an UNSUBSCRIBE of a restored filter found no subscription. They are recorded when the streams are reopened. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoVCzGPCAFKe3smSge2
…hed filters Failing filters in the SUBACK is only valid when every filter on the reset stream belongs to a pending SUBACK. A stream that also carries restored filters or filters of an earlier acknowledged SUBSCRIBE ends the connection with the reset reason code, as before the SUBACK waited for the application streams to begin. Pending SUBACKs are kept in arrival order so back-to-back SUBSCRIBEs are acknowledged in order. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoVCzGPCAFKe3smSge2
…r resubscribe A shared SUBSCRIBE is unsubscribed and subscribed again, opening a second stream under the same filter. The first stream's reply direction is then aborted by the application, and the second stream keeps delivering and acknowledging at-least-once messages and still ends on UNSUBSCRIBE, in MQTT 5. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoVCzGPCAFKe3smSge2
… abort of the previous stream Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoVCzGPCAFKe3smSge2
…stream closes late Closing a shared subscribe stream removed whatever stream was registered under its filter, so a late close of a stream already unsubscribed removed the stream opened by a later SUBSCRIBE of the same filter, and UNSUBSCRIBE could no longer reach it. A shared stream is removed only while it is the registered one, as for non-shared streams. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoVCzGPCAFKe3smSge2
A subscribe stream whose reply direction is aborted before it begins fails only the filters of its pending SUBACK with the unspecified failure code, leaving the connection open, in MQTT 3.1.1 and 5. One of two shared filters failing yields a failure and a granted code, and a stream that also carries a restored filter ends the connection. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoVCzGPCAFKe3smSge2
…to fail its subscribe acknowledgement Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoVCzGPCAFKe3smSge2
…am aborts before it begins A subscribe stream whose reply direction was aborted or ended before it began never completed the SUBACK waiting for it, leaving the client without a reply. It now takes the path of a reset before begin: the SUBACK fails the filters of the pending SUBACK with the unspecified failure code when the stream carries only those filters, and a stream that also carries established filters ends the connection. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoVCzGPCAFKe3smSge2
…n the stream aborts before it begins An UNSUBSCRIBE received while a SUBSCRIBE waits for its application stream is acknowledged after the SUBACK fails that filter, reporting that no subscription existed, in MQTT 5. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoVCzGPCAFKe3smSge2
…tream aborts before it begins Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoVCzGPCAFKe3smSge2
…ribe stream A subscribe stream ended its initial direction without recording it, so a later reset or abort of the same stream could not tell it from a live one and an abort was still sent on the ended direction. Mark the direction closed when it is ended, as the abort path already does, and stop sending flushes on it. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoVCzGPCAFKe3smSge2
…gement scenarios Convert the acknowledgement scenarios to the version-aware session state builder and add MQTT 3.1.1 variants of the application scripts, which carry no subscription ids. 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-4-mqtt-suback-gating
branch
from
November 17, 2026 06:34
9a3d35f to
e2d4690
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
binding-mqttnow sends SUBACK only after the reply BEGIN of every application stream opened for the SUBSCRIBE, so a message published right after SUBACK is not lost. This is required by shared subscriptions, where the backing stream is a Kafka share group member that only starts receiving once it has joined, and it also removes the same race for ordinary subscriptions. The layer also hardens the stream lifecycle edge cases that this gating exposes.Part of #1801
SUBACK waits for application stream BEGIN
Stream lifecycle fixes found along the way
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 / 548specs/binding-mqtt-kafka.spec: 32 / 263runtime/binding-mqtt: 63 / 453runtime/binding-mqtt-kafka: 29 / 152Notes for reviewers
🤖 Generated with Claude Code
https://claude.ai/code/session_01SiHVoVCzGPCAFKe3smSge2