Repository navigation
feat(binding-kafka): share group stream for Kafka share groups - #3109
Merged
jfallows merged 24 commits intoNov 17, 2026
Merged
Conversation
This was referenced Nov 11, 2026
jfallows
force-pushed
the
feature/mqtt-shared-subscriptions-1-kafka-share
branch
from
November 12, 2026 21:28
c27dba1 to
20210c7
Compare
Describe a Kafka share group client stream (KIP-932): begin carries the group id, member id, topic, filters and the maximum number of records in flight; data carries the acquired record with its partition offset and delivery count; flush carries a per-record acknowledgement of ACCEPT, RELEASE or REJECT with an optional correlation. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoVCzGPCAFKe3smSge2
Add paired client and server k3po scripts for the share stream at the application level and at the wire level (FindCoordinator v6, Metadata v13, ShareGroupHeartbeat v1, ShareFetch v1, ShareAcknowledge v1), with spec-level ITs for both protocol sides and a client IT that drives the scripts against the engine. Scenarios cover receiving records, fragmented delivery, acknowledging with ACCEPT, RELEASE and REJECT piggybacked on the next fetch or sent as an explicit acknowledge, filtering of non-matching records, multiple partitions, assignment changes, flow control bounded by the stream window and the records in flight, leaving the group, and error handling for coordinator, member, topic and authorization failures. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoVCzGPCAFKe3smSge2
… reset in specs Every share group connection begins with an ApiVersions v0 exchange, ahead of any SASL handshake and request, and the chosen version of each API used on the connection (Metadata 13, FindCoordinator 6 on the bootstrap connection, ShareGroupHeartbeat 1 on the coordinator, ShareFetch 1 and ShareAcknowledge 1 on the partition leader) must fall within the advertised range. An absent API or an excluded range rejects the stream with UNSUPPORTED_VERSION. Adds scenarios for an absent share API, version range mismatch on the bootstrap, coordinator and leader connections, application ABORT and RESET mid-stream, and network abort of the coordinator and leader connections mid-session. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoVCzGPCAFKe3smSge2
Adds flexible-version codec scopes for Metadata v13, FindCoordinator v6, ShareGroupHeartbeat v1, ShareFetch v1 and ShareAcknowledge v1. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoVCzGPCAFKe3smSge2
…r share group KafkaRecordFilter evaluates ORed filters of ANDed key, header, headers and not conditions over a decoded record, with the same semantics as the cache filter conditions. KafkaShareRanges tracks disjoint ordered offset ranges. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoVCzGPCAFKe3smSge2
Handles the SHARE stream kind with one share group member per stream: per-connection ApiVersions negotiation, Metadata and FindCoordinator on a bootstrap connection, ShareGroupHeartbeat on the coordinator connection, and ShareFetch and ShareAcknowledge on each partition leader connection, with acknowledgements piggybacked on fetch and a graceful leave on stream close. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoVCzGPCAFKe3smSge2
… error A broker without the share feature enabled still advertises the share APIs but answers ShareGroupHeartbeat with UNSUPPORTED_VERSION, which resets the stream. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoVCzGPCAFKe3smSge2
… from share data The share stream delivers every record of a fetch response as it streams and reports the acquired offset ranges with their delivery counts in a reply flush once a partition's records are complete, so the per-record data extension no longer carries a delivery count. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoVCzGPCAFKe3smSge2
…sion rejected events Share record data frames now precede the acquired ranges flush of their partition; add scenarios for a record larger than the decode slot, a batch of records, records outside the acquired ranges, acquired offset gaps and compressed batches. Remove the client-level key filter scenarios, assert the api version rejected event in the unsupported version scenarios. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoVCzGPCAFKe3smSge2
…n specs Report the whole batch of a flow controlled response in one acquired ranges flush and match the api version rejected event messages formatted by the binding. 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 event formatter resolved no title for the share group heartbeat, share fetch and share acknowledge api keys and failed on events raised for them. 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
… response Decode the share fetch response progressively so a record or batch larger than the decode slot streams to the application in fragments. Records are delivered as they are decoded and the acquired offset ranges with their delivery counts are reported in a reply flush once the acquired records of a partition are decoded. Offsets acquired but not delivered are accepted or rejected, and the client no longer evaluates record filters. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoVCzGPCAFKe3smSge2
…tream credit Share fetch requests carry the same static limits on every request, taken from configuration like the regular fetch: the maximum bytes of a response and the maximum records (also the batch size) of a response. The share begin extension no longer carries a records limit, and the application window only paces delivery of already requested records. Add the client.share.fetch.max.bytes and client.share.fetch.max.records properties. Scenarios that relied on a records limit to hold back the next fetch until an acknowledgement was written now withhold the end of the response until the acknowledgement is written, so the acknowledgement piggybacks on the next fetch. Replace the window scenario with a response larger than the application window delivered across window replenishments, add leaving while a fetch is outstanding, and remove the scenarios that exercised a records limit or a standalone acknowledge while the stream could not fetch. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoVCzGPCAFKe3smSge2
…tream credit Send the configured maximum bytes, maximum records and batch size on every share fetch, as the regular fetch does, instead of deriving them from the application window and the unacknowledged record count. The next request is sent once the previous response has been completely consumed; the application window only paces delivery of requested records and network backpressure holds the rest. Acquired but unacknowledged offsets are still tracked for acknowledgement piggybacking and release on leave, but no longer gate fetches. Acknowledgements always piggyback on the next share fetch, so the standalone acknowledge request is now only sent when leaving, and the unused records count helper is removed. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoVCzGPCAFKe3smSge2
…unt and optional member id The share acquired flush reports the acquisition lock timeout of the fetch response so a consumer of the stream knows how long the acquired records stay locked. The share data extension reports the delivery count of a record, 0 meaning not reported, and the share begin extension makes the member id optional for streams that do not own a share group member. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoVCzGPCAFKe3smSge2
…uired flush Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoVCzGPCAFKe3smSge2
… the kafka cache The kafka cache server holds one share group member per share group and fans out the acquired records to the share streams attached to the group, distributing each record to exactly one stream, returning the records of a stream that ends to the other streams and releasing the records when the last stream ends. Records are held until their acquired range is known, filtered on the complete record, dropped when their acquisition lock expires and withheld from delivery when too little lock time remains. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoVCzGPCAFKe3smSge2
…rios on stream readiness Wait for the share stream to receive the record before the member stream aborts, wait for the first acknowledgement before the second record is distributed, and observe the reset of the initial direction before the abort of the reply direction, as the cache group scenarios do. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoVCzGPCAFKe3smSge2
The kafka cache server holds one share group member per binding and share group id and fans the acquired records out to the share streams attached to the group. Records are staged in an ephemeral cache partition as they are streamed, held until the acquired flush names their offset, evaluated against the group filters on the complete record, and delivered to exactly one attached stream with window, in rotation. Acknowledgements are forwarded to the member stream and confirmations are routed back to the originating stream by correlation. The records of a stream that ends are redelivered to the other streams, and the records are released when the last stream ends. Records are dropped when their acquisition lock expires and are released instead of delivered when too little lock time remains. The member stream is granted window only while the acquired records held stay under a bound. The cache client keeps a share stream per attached stream as a pass-through. Add the cache.server.share.staging.max.bytes, cache.server.share.staging.segment.bytes and cache.server.share.lock.margin.percent properties. The record filter evaluates the headers of a cache entry. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoVCzGPCAFKe3smSge2
…timeout and uncorrelated rejected acknowledgement The acquired flush reports the broker lock timeout minus the time elapsed since the share fetch that produced the response was sent, floored at zero, so a response held back in the network buffer does not overstate the remaining lock. An engine clock that advances by a fixed step makes the delayed response deterministic. When the lock of a record held by the cache lapses before it is acknowledged, the fan-out releases the record to the member stream instead of dropping it. The expiry is driven by the signaler, held records are not delivered because the attached stream has no window, and the release is awaited as an ordinary frame. A lock that has already lapsed on arrival is released the same way. A release the broker rejects as an invalid record state does not fail the share stream and the offset no longer counts as in flight when leaving. The staging bound scenario streams records larger than the member stream credit, so the window withheld at the bound is exhausted and the stream only completes when the bound resumes the window. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoVCzGPCAFKe3smSge2
…an assignment change revokes the partition An acknowledgement the application has requested a confirmation for and that is still to be sent cannot reach the broker once the partition is revoked from the member, so the confirmation reports an invalid record state instead of success. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoVCzGPCAFKe3smSge2
…ords and confirm revoked acknowledgements The client factory reports the lock timeout of an acquired flush as the broker lock timeout minus the time elapsed since the share fetch that produced the response was sent, floored at zero, so a response held back in the network buffer does not overstate the lock that remains. The cache fan-out releases a record to the member stream when its lock expires, whether or not it was delivered, instead of dropping it. The broker rejects a release for a lapsed or reacquired record as an invalid record state without affecting the member, and the client factory has already cleared the offset from its in-flight set when the acknowledgement was accepted, so the rejection of an uncorrelated acknowledgement is ignored. A confirmation requested for an acknowledgement that is still to be sent when an assignment change revokes the partition now reports an invalid record state, as the acknowledgement can no longer reach the broker, instead of reporting success when the next fetch completes. The staging bound documentation states that the bound gates acknowledgement and can be exceeded by one response, so it needs no relation to the share fetch size. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoVCzGPCAFKe3smSge2
jfallows
force-pushed
the
feature/mqtt-shared-subscriptions-1-kafka-share
branch
from
November 17, 2026 01:45
20210c7 to
c50ab79
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
Adds a
SHAREstream kind tobinding-kafkafor consuming Kafka share groups (KIP-932): per-record acquisition, acknowledgement and redelivery, with no partition ownership or owner election. This layer is the specs, the share protocol, the client factory and the cache fan-out. It does not depend on any other binding.Part of #1801
SHARE stream contract
filters.deliveryCount(0 on the client hop means not reported).lockTimeoutMillisand the acquired ranges with delivery counts.Client factory
FindCoordinatorv6,ShareGroupHeartbeat,Metadatav13 (topic ids),ShareFetchandShareAcknowledgev1, withApiVersionsnegotiated per connection. An unsupported broker fails the stream and emitsBINDING_KAFKA_API_VERSION_REJECTED.client.share.fetch.max.bytes,.max.records,.max.wait.millis,.min.bytes.Cache fan-out
(binding, group id, topic)per worker and fans out in process; the cache client is a 1:1 pass-through.Kafka requirements
Kafka 4.1+ with the
share.version=1feature enabled. Share groups are a preview in 4.1.Tests (test-first order is kept in the commit history)
specs/binding-kafka.spec: application and networksharescripts,ShareIT(network and application) andShareCacheIT.runtime/binding-kafka:ClientShareIT,CacheShareIT, and unit testsKafkaShareRecordsTest,KafkaShareRangesTest,KafkaShareLockTest.Stack
This is one layer of a stack of PRs for #1801. Each PR contains only the commits since the previous layer; merge in order.
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 against
origin/develop57b7546 (checkstyle and license checks run in thevalidatephase of each build):./mvnw clean install -DskipTests -pl specs/binding-kafka.spec,runtime/binding-kafka -am -Dmaven.build.cache.enabled=false: OK./mvnw clean verify -pl specs/binding-kafka.spec,runtime/binding-kafka -Dmaven.build.cache.enabled=false: OKspecs/binding-kafka.spec: 255 unit tests and 589 spec ITs, 0 failuresruntime/binding-kafka: 257 unit tests and 495 ITs, 0 failures (ClientShareIT40 andCacheShareIT22 pass with none skipped)Notes for reviewers
🤖 Generated with Claude Code
https://claude.ai/code/session_01SiHVoVCzGPCAFKe3smSge2