Repository navigation
feat(binding-mqtt): MQTT 5 shared subscriptions in server and client - #3110
Merged
Conversation
This was referenced Nov 11, 2026
jfallows
force-pushed
the
feature/mqtt-shared-subscriptions-2-mqtt-server-client
branch
from
November 12, 2026 21:28
f4411f7 to
0c60904
Compare
Add an optional shareName to MqttTopicFilter, bump MqttSessionState to version 2, and keep the version 1 layout readable through MqttTopicFilterV1 and MqttSessionStateV1. MqttFunctions gain sharedFilter and sharedSubscription builders, a shared filter begin matcher and a version 1 session state builder. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoVCzGPCAFKe3smSge2
Add an optional share condition to when[].subscribe[] in the schema, the condition config, builder and adapter. The value is a share name or a wildcard. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoVCzGPCAFKe3smSge2
Add paired network and application scripts, spec ITs and runtime ITs for shared subscriptions: stream per shared subscription, share name and filter identity, shared with non-shared filters, QoS change on re-subscribe, unsubscribe, malformed and no-local rejection, share route condition, delivery at the lower of message and granted QoS, restore on reconnect from version 2 and version 1 session state, and MQTT 3.1.1 filters declined in the SUBACK. Correct the topic filter length in the unsupported shared subscription script. 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
Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoVCzGPCAFKe3smSge2
Recognize a shared subscription by its $share/ prefix and validate the share name and topic filter. A shared subscription is identified by its share name and topic filter, opens one application subscribe stream at the granted QoS, ignores retain handling and rejects no local. Re-subscribing updates the granted QoS with a filter flush, and unsubscribing ends the stream. Messages are delivered at the lower of the message QoS and the granted QoS. Match the share condition when routing a subscription. Persist the share name in version 2 of the session state and keep reading version 1. Decline a shared subscription from an MQTT 3.1.1 client with a SUBACK failure code and remove the unused shared subscription property. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoVCzGPCAFKe3smSge2
…n state by version Add reasonCode to MqttSubscribeFlushEx so an acknowledgement reason code can travel with a PUBACK or PUBREC. The session state builder writes version 1 unless a shared subscription is present, in which case it writes version 2, so state without shared subscriptions stays readable by earlier versions. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoVCzGPCAFKe3smSge2
…hared subscriptions Add paired network and application scripts, spec ITs and runtime ITs for PUBACK and PUBREC reason codes of at least 0x80 on QoS 1 and QoS 2 delivery, for shared QoS 1 delivery, and for a CONNACK that declines shared subscriptions. Run QoS 1 and QoS 2 delivery, shared subscribe, re-subscribe, unsubscribe and mixed shared and non-shared subscriptions against the client binding, with the shared subscription options a client sends carrying retain handling that sends no retained messages. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoVCzGPCAFKe3smSge2
…ipeline for mqtt Return the granted QoS in the session state echoed after a subscribe, add session state builders that carry a reason code, and add network scripts for the upstream side of a server binding routed to a client binding. Cover shared and non-shared QoS 1 and QoS 2 delivery with acknowledgement reason codes, mixed shared and non-shared subscriptions and a declined shared subscription. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoVCzGPCAFKe3smSge2
…on codes through the server-to-client pipeline Add an IT for a server binding routed to a client binding, a unit test for the session state codec and reason code classification, and the mixed shared and non-shared message scenario for the server and client bindings. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoVCzGPCAFKe3smSge2
…ssion state by version Forward the reason code of a PUBACK or PUBREC to the subscribe stream. A PUBREC with a reason code of at least 0x80 ends the QoS 2 exchange: no PUBREL follows, the packet identifier is released and the subscribe window is reopened. Write session state as version 1 unless a subscription has a share name, and read either version, through a shared codec. Correct the session data reservation check for a padded session stream. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoVCzGPCAFKe3smSge2
…ivery in the client binding Send a shared subscription upstream as $share/<name>/<filter> in SUBSCRIBE and UNSUBSCRIBE, carry the requested QoS in the subscription options and deliver to one application stream per shared subscription. Decode QoS 1 and QoS 2 PUBLISH packets with their packet identifier, send PUBACK, PUBREC and PUBCOMP with the reason code the application acknowledged with, and relay PUBREL to the stream that holds the QoS 2 exchange. Replace a subscription that is subscribed again instead of unsubscribing it, read and write session state of either version, and do not treat a server keep alive property as a repeated shared subscription available property. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoVCzGPCAFKe3smSge2
… a version Forward the session state payload as written instead of wrapping it with the latest layout, so state of version 1 or version 2 passes through unchanged. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoVCzGPCAFKe3smSge2
… mqtt client Add paired network, application and upstream scripts and spec ITs for a QoS 2 PUBLISH retransmitted before the acknowledgement, after PUBREC was sent, after the exchange completed and after PUBREC with a reason code of at least 0x80, together with the network scripts of a client that receives the de-duplicated deliveries. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoVCzGPCAFKe3smSge2
…t the client Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoVCzGPCAFKe3smSge2
…elivering it again A QoS 2 PUBLISH that reuses the packet identifier of an exchange still in progress is not delivered again. It is dropped while the acknowledgement is pending, and answered with the PUBREC reason code already sent once the acknowledgement was sent. The packet identifier is free again once PUBCOMP is sent or PUBREC carried a reason code of at least 0x80. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoVCzGPCAFKe3smSge2
…on 2 Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoVCzGPCAFKe3smSge2
… the session path Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoVCzGPCAFKe3smSge2
…ion layouts Declare the session state as a union switched on its version so the same flyweight reads and writes version 1 and version 2 layouts. The wire layout of each version is unchanged. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoVCzGPCAFKe3smSge2
…ion union Replace the version peeking codec with the session state flyweight, selecting the layout by its version when reading and writing version 1 unless a subscription is shared. 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
… in mqtt subscribe dump The mqtt topic filter now carries an optional share name and the subscribe flush carries the acknowledgement reason code. Add a shared subscription scenario that acknowledges a delivery with a reason code, and expect the extra bytes of the optional share name in the existing subscribe scenario. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoWETrA5Cn7uqKAtsMH
… of mqtt subscribe Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoWETrA5Cn7uqKAtsMH
…a output Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoWETrA5Cn7uqKAtsMH
…pts with per-filter acknowledgement reason codes Use the version-aware session state builder in the qos 2 de-duplication scripts, flush failed pubrec acknowledgements as complete with their reason code, and open the shared session state kafka scripts with the retained topic describe. 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-2-mqtt-server-client
branch
from
November 17, 2026 03:50
0738149 to
95de3bb
Compare
…n the client binding Answer a failed qos 2 acknowledgement with PUBREC carrying its reason code and release the packet id, and record a granted qos from SUBACK as success in the session state. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoWETrA5Cn7uqKAtsMH
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
Adds MQTT 5 shared subscriptions (
$share/<ShareName>/<filter>, MQTT 5.0 section 4.8.2) tobinding-mqtt: the server side, acknowledgement reason codes, the client side, the versioned session state and QoS 2 de-duplication. It is the protocol layer that the Kafka-backed delivery in the next PR builds on.Part of #1801
Server
$share/<ShareName>/<filter>is parsed and validated. The application sees the stripped filter plusshareNameinMqttTopicFilter. A shared subscription is identified by(ShareName, filter), and there is one application subscribe stream per shared subscription.noLocalis a protocol error (3.8.3-4). Delivery is atmin(message QoS, granted). MQTT 3.1.1 clients get SUBACK0x80for a$sharefilter.shareroute condition (exact name or*glob). Omitted means no constraint on the share name. A route withsharedoes not match non-shared subscriptions.Acknowledgements
MqttSubscribeFlushExcarries the PUBACK or PUBREC reason code. A PUBREC at 0x80 or above ends the exchange with no PUBREL (4.8.2-6) and is flushed as complete with its reason code.MqttPublishFlagsgainsDUPfor a redelivered PUBLISH.develop; a shared subscription that no route matches is answered with a per-filter failure.Session state
MqttSessionStatebecomes an enum-switched union (V1, V2, V3). Version 1 is the legacy layout with generated subscription ids, version 2 is the layout released ondevelop, and version 3 addsshareName. Version 2 is still written unless a subscription is shared, so rolling upgrades stay safe. The wire layouts are pinned by spec tests.Client (mqtt server to mqtt client pipeline)
QoS 1 and 2 inbound from the upstream broker, with de-duplication of a retransmitted QoS 2 PUBLISH,
$share/<name>/<filter>sent upstream, acknowledgements and reason codes relayed, and session state of all versions.Also in this layer
binding-mqtt-kafkaandbinding-mqtt-kafka.specget a small adaptation so session state is forwarded in the layout of its own version, and a session-state pass-through spec for a shared subscription.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 verify -pl specs/binding-mqtt.spec,specs/binding-mqtt-kafka.spec,runtime/binding-mqtt,runtime/binding-mqtt-kafka,runtime/binding-asyncapi,specs/binding-asyncapi.spec,incubator/command-dump,incubator/command-log,config/binding-mqtt.conf,config/binding-mqtt-kafka.conf -Dmaven.build.cache.enabled=false: OK (0 failures)Notes for reviewers
🤖 Generated with Claude Code
https://claude.ai/code/session_01SiHVoWETrA5Cn7uqKAtsMH