Repository navigation
feat(binding-mqtt-kafka): shared subscriptions for QoS 0 and 1 over Kafka share groups - #3111
Merged
jfallows merged 25 commits intoNov 17, 2026
Conversation
This was referenced Nov 11, 2026
jfallows
force-pushed
the
feature/mqtt-shared-subscriptions-3-mqtt-kafka-share
branch
from
November 12, 2026 21:28
9e67350 to
104cf9b
Compare
jfallows
force-pushed
the
feature/mqtt-shared-subscriptions-3-mqtt-kafka-share
branch
from
November 12, 2026 21:45
104cf9b to
d7ad9b9
Compare
Add an optional store reference to the binding options and an optional share name or wildcard to subscribe route conditions. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoVCzGPCAFKe3smSge2
Carry the store reference in the binding options and pair each subscribe topic of a condition with an optional share name. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoVCzGPCAFKe3smSge2
Match each condition topic together with its share name. An omitted share places no constraint and a share condition never matches a subscription that is not 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
The share data extension builder only wrote text header values, so a script could not express headers that carry a binary integer. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoVCzGPCAFKe3smSge2
Specify the session capability, granted QoS, and shared subscribe streams against Kafka share streams, including acknowledgement, expiry, reset and route share conditions. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoVCzGPCAFKe3smSge2
…he proxy 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
…and cap their granted qos Advertise the shared subscriptions capability only when the property is enabled and the binding declares a store. A shared subscription is granted at most QoS 1 in the session state returned to the mqtt binding. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoVCzGPCAFKe3smSge2
…re streams Open one Kafka share stream per shared subscription with a group id derived from the share name and the encoded topic filter. Map share records to subscribe messages and map acknowledgements to ACCEPT or REJECT. Messages that cannot be delivered are accepted when expired and rejected when fragmented. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoVCzGPCAFKe3smSge2
… record Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoVCzGPCAFKe3smSge2
…gmented share record The share fan-out delivered a record's headers on the first data frame only when the record was delivered whole, so a record delivered in fragments carried them on the final frame alone. The staged record is complete before delivery, so the first frame now always carries the record's headers beside its key, mirroring the fetch cache path, which carries headers on both the first and final frames. The final frame keeps carrying headers, as the fetch path does, so a reader of either frame sees them. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoVCzGPCAFKe3smSge2
Replace the scenario that rejected a fragmented share record with scenarios that deliver it. The first frame carries the record's key and headers, so a fragmented QoS 1 message is acknowledged with PUBACK and accepted, a fragmented QoS 0 message is accepted after its final frame, a fragmented expired message is skipped and accepted, and a fragmented QoS 1 message acknowledged with a failure reason code is rejected. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoVCzGPCAFKe3smSge2
…ages A share record delivered in fragments is no longer rejected. Its first frame carries the key and headers, so the first MQTT frame is built from them, including the remaining length as deferred, and the continuation and final frames are forwarded as they arrive, as for a subscription that is not shared. The delivery state of the record in progress is held as a decoder state: deliver, or skip for an expired record whose frames are swallowed. A packet id is allocated on the first frame for a message delivered at QoS 1 or above. The record is accepted after its final frame when it is delivered at QoS 0 or was skipped, and otherwise on the acknowledgement of its packet id. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoVCzGPCAFKe3smSge2
…to epoch The group id of a shared subscription ends with its epoch, which keeps the value "0" until the epoch is taken from the subscription registry. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoVCzGPCAFKe3smSge2
Replace the parallel topic and share lists of a mqtt-kafka condition with a subscribe config that carries a topic and an optional share, as mqtt does, and match each entry as a pair. The subscribe and publish shapes of a condition in zilla.yaml are unchanged. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoVCzGPCAFKe3smSge2
Two clients subscribed to the same filter each receive their own first qos 1 message with packet id 1 and acknowledge it independently. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoVCzGPCAFKe3smSge2
Allocates ids in 1..65535, wraps without yielding 0, skips ids still in flight and reports exhaustion instead of failing the worker. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoVCzGPCAFKe3smSge2
…ribe messages Fails until packet ids are allocated per client: the second client receives packet id 2 instead of 1. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoVCzGPCAFKe3smSge2
Packet ids are allocated per client and start again at 1 once the client has no open subscribe streams. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoVCzGPCAFKe3smSge2
A single worker-wide counter handed out ids above 65535, which fails the flyweight builder and terminates the engine worker, and let unrelated clients share one id space. Each client now owns a bounded id allocator and its in-flight id to offset mapping, shared by all its subscribe streams on the worker and released when the last of them closes. When all 65535 ids of one client are in flight the stream is aborted rather than failing the worker. 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
…blish conditions The mqtt-kafka condition builder pairs each subscribe topic with its share and lists publish topics separately, so the generated route calls subscribe() or publish(topic) instead of the removed topic() and kind(). Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoVCzGPCAFKe3smSge2
…afka in the inspect.schema output Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoWETrA5Cn7uqKAtsMH
…tained describe and per-client offsets Open the shared session scenarios with the retained topic describe, expect the publish qos max configured by the test, position the second client of the multiple client scenario at its own offset, and drop the shared reject fragmented message scenario that the fragmented delivery replaced. 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-3-mqtt-kafka-share
branch
from
November 17, 2026 05:45
d7ad9b9 to
ac1a6a5
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
Maps MQTT 5 shared subscriptions onto Kafka share groups in
binding-mqtt-kafkafor QoS 0 and 1. Before this PR a$sharesubscribe was rejected with0x9E; with the capability enabled and a store configured it is granted and delivered through aSHAREstream, so each matching message reaches exactly one session in the shared subscription.Part of #1801
Configuration and capability
zilla.binding.mqtt.kafka.shared.subscription.available(defaulttrue). The capability is advertised only when the property is enabled and the binding hasoptions.store. Otherwise CONNACK advertises Shared Subscription Available = 0 and$shareis rejected with0x9E, as before.shareroute condition on mqtt-kafka routes, as a topic and share pairing. A shared subscription with no matching route is rejected. Schema and config adapter updated, including a store option.share.versionnot enabled) fails the SUBSCRIBE with SUBACK0x83and the eventBINDING_KAFKA_API_VERSION_REJECTED.KafkaSharedProxy
SHAREstream per shared subscription and maps data and headers, including fragmented records carried viadeferred. The share group id is derived from the group id prefix, the share name and the filter.SHAREstream. Granted QoS of a shared subscription is capped per subscriber.Per-client packet ids
Packet ids are allocated per client in 1..65535 (wrap, never 0, skipping ids in flight) by a bounded allocator, replacing the factory-wide counter that overflowed uint16 (#3064).
Also in this layer
binding-kafkaandbinding-kafka.spec: a follow-up to the share stream from the first PR so that record headers are carried on the first frame of a fragmented share record (with its spec), and an integer header builder in the share data extension spec functions.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,config/binding-mqtt.conf,config/binding-mqtt-kafka.conf,specs/binding-kafka.spec,runtime/binding-kafka -Dmaven.build.cache.enabled=false: OK (unit tests / ITs, 0 failures)specs/binding-kafka.spec: 256 / 591specs/binding-mqtt.spec: 93 / 494specs/binding-mqtt-kafka.spec: 32 / 262runtime/binding-kafka: 257 / 496runtime/binding-mqtt: 63 / 421runtime/binding-mqtt-kafka: 29 / 151config/binding-mqtt-kafka.conf: 21 unit testsNotes for reviewers
binding-mqtt(SUBACK gated on application stream BEGIN, UNSUBSCRIBE draining), and later PRs add QoS 2 delivery with durable claim tickets and the subscription lifecycle. Known limitations are tracked in Support MQTT 5 Shared Subscriptions via Kafka share groups #1801.🤖 Generated with Claude Code
https://claude.ai/code/session_01SiHVoVCzGPCAFKe3smSge2