Repository navigation
feat(binding-mqtt-kafka): QoS 2 claim tickets for shared subscriptions - #3114
Merged
jfallows merged 29 commits intoNov 17, 2026
Merged
Conversation
This was referenced Nov 11, 2026
jfallows
force-pushed
the
feature/mqtt-shared-subscriptions-6-qos2-claim-tickets
branch
from
November 12, 2026 21:28
deada99 to
150db14
Compare
jfallows
force-pushed
the
feature/mqtt-shared-subscriptions-6-qos2-claim-tickets
branch
from
November 12, 2026 21:45
150db14 to
20f262a
Compare
jfallows
force-pushed
the
feature/mqtt-shared-subscriptions-6-qos2-claim-tickets
branch
from
November 17, 2026 07:54
20f262a to
cd451c2
Compare
Base automatically changed from
feature/mqtt-shared-subscriptions-5-mqtt-unsubscribe-drain
to
develop
November 17, 2026 18:36
Let the test store declare an ordered list of expected entry mutations (put, putIfAbsent, delete, getAndDelete with key, value and ttl). When the list is configured, each mutation must match the next expectation or the operation fails with an assertion error, so integration tests can prove what was written and in which order. Omitting the list keeps every operation unchecked and an empty list expects no mutation at all. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoVCzGPCAFKe3smSge2
Add a versioned union holding a client's tickets, each with its packet id, state, topic, partition and offset. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoVCzGPCAFKe3smSge2
Encode a client's ticket list with the versioned flyweight as unpadded base64url so it fits a string-valued store, and decode it back, reporting an unrecognised version so it is never rewritten. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoVCzGPCAFKe3smSge2
Add scripts for shared qos 2 messages whose claim ticket is written before the message is accepted and delivered: the full PUBREC, PUBREL and PUBCOMP exchange, a rejecting PUBREC, a fragmented message, two messages in quick succession, an expired message and pre-existing tickets. Grant shared subscriptions up to qos 2 and drop the scenario that rejected qos 2 acknowledgements. Declare the expected store writes in test configurations. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoVCzGPCAFKe3smSge2
…ickets Run the shared qos 2 scenarios against the proxy with a test store that asserts each ticket write, and expect no store writes when a qos 2 message is delivered at qos 1. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoVCzGPCAFKe3smSge2
When the test store declares expected entry mutations, fail the store detach if any expectation was never consumed, so a mutation that should have happened and did not is reported instead of passing silently. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoVCzGPCAFKe3smSge2
Keep the stored qos of the shared reconnect scenario as requested now that shared subscriptions are granted qos 2, and refuse a shared subscription whose stored ticket list cannot be read rather than overwrite it. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoVCzGPCAFKe3smSge2
…a shared subscription Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoVCzGPCAFKe3smSge2
…claim tickets Attach the binding store, load the client's ticket list when its first shared subscribe stream begins, and write a ticket before a qos 2 message is accepted and delivered. Hold the frames of the message in a buffer slot, without crediting Kafka for them, until the coalesced write that contains the ticket completes, then accept the record and forward the frames in order. PUBREC moves the ticket to PUBREL pending and sends the release, while PUBCOMP or a PUBREC with a reason code of 0x80 or above removes it. Grant shared subscriptions up to qos 2. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoVCzGPCAFKe3smSge2
…re detach Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoVCzGPCAFKe3smSge2
Add a dup flag to the subscribe data extension flags and specify the network publish of a redelivered message at qos 1 and qos 2 with the dup bit set. 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
Set the dup bit of a publish packet for a qos 1 or qos 2 message when the subscribe data extension carries the dup flag, so a resent message is identifiable to the receiver. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoVCzGPCAFKe3smSge2
Add the share name and the filter of the owning shared subscription to the ticket, and update the stored ticket values of the test configurations. The ticket of an unrelated subscription is seeded for the existing tickets scenario. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoVCzGPCAFKe3smSge2
… tickets Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoVCzGPCAFKe3smSge2
…d qos 2 tickets Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoVCzGPCAFKe3smSge2
…t tests Move the stored ticket list of a client, with its load, coalesced write and completion handling, out of the subscribe factory so its behavior is covered without a stream, and add the lookup of tickets by owning subscription and the clearing of the list. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoVCzGPCAFKe3smSge2
…the in-flight write Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoVCzGPCAFKe3smSge2
…hen a shared stream ends When a shared stream ended while the write of a ticket was pending, the message was never accepted and was released to another member, yet the ticket still reached the store, so a later reconnect would resend a message the client never received. Remove those tickets once the in-flight write completes and release their packet ids. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoVCzGPCAFKe3smSge2
Specify resending the release of a ticket awaiting release, and refetching the message of a ticket awaiting acknowledgment by its exact topic, partition and offset to redeliver it with the same packet id and the dup flag, then removing the ticket on completion. A refetched message at a different offset, an expired message and a missing message drop the ticket without delivery, a recovered message is delivered before a new one, and a fragmented message is recovered. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoVCzGPCAFKe3smSge2
…reconnect Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoVCzGPCAFKe3smSge2
…sage A dropped ticket is removed from the store before the next message is delivered, so its packet id is free again and the next message reuses it. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoVCzGPCAFKe3smSge2
…per subscription Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoVCzGPCAFKe3smSge2
…ption is restored Once the tickets of a client are loaded and the shared stream begins, resend the release for each ticket of the subscription awaiting release, and refetch the message of each ticket awaiting acknowledgment by its exact topic, partition and offset to redeliver it with the same packet id and the dup flag. A refetched message at a different offset, an expired message or a missing message drops the ticket once its removal is durable. New messages wait for the recovery to finish so recovered packet ids are not reused. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoVCzGPCAFKe3smSge2
…nation Specify that a session starting clean, a session closing without an expiry and an expiring session discard the stored tickets of the client, while a session closing with an expiry keeps them. 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
… discarded Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoVCzGPCAFKe3smSge2
…mination Delete the stored tickets of a client when its session starts clean, when a session without an expiry closes and when the expiry of a session elapses, and release the packet ids of the discarded tickets held for the client. The discard goes through the per-client ticket list of the subscribe factory, which orders it with any write in flight and drops the list once idle. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoVCzGPCAFKe3smSge2
…ession behavior Merge the claim ticket state into the per client high water marks, convert the redeliver scenarios to the version-aware session state builder with an MQTT 3.1.1 variant of the qos 2 application script, and open the session close scenario 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-6-qos2-claim-tickets
branch
from
November 17, 2026 18:36
cd451c2 to
0e70d12
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 QoS 2 delivery for shared subscriptions in
binding-mqtt-kafkausing durable claim tickets in the configured store, so a QoS 2 message completes PUBREL and PUBCOMP to the same client across reconnects, including through another node, and is never sent to another subscriber once it has been claimed (MQTT 5.0 4.8.2-4 and 4.8.2-5).Part of #1801
Claim tickets
{packetId, state, topic, partition, offset, shareName, filter}is written to the store under<groupIdPrefix>:tickets:<clientId>(a versioned flyweight union, base64url encoded). Writes are coalesced. The record's frames are held until the write is durable, then the record is ACCEPTed and forwarded.binding-mqtt
An encoded
DUPflag on a redelivered PUBLISH, with spec and IT first.Engine test store
The
type: teststore gains anassertionsoption of expected mutations (put,putIfAbsent,delete,getAndDelete) that ITs use to assert the order and content of the entries a binding writes, and it fails the test at detach when expected operations are missing. The config schema and adapter, spec scenarios and unit tests (TestStoreHandlerTest) are included.TestEntryis public because the publicTestStoreHandlerconstructor takes it, and the ticket unit tests seed and readTestEntryvalues.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/engine.spec,config/engine.conf,runtime/engine,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/engine.spec: 57 / 107runtime/engine: 322 / 262specs/binding-mqtt.spec: 100 / 606specs/binding-mqtt-kafka.spec: 42 / 290runtime/binding-mqtt: 63 / 485runtime/binding-mqtt-kafka: 55 / 169Notes for reviewers
TestEntry) change it required is folded into the commit that introduced the ticket unit tests, so every commit from there on compiles its tests. The tree of the stack tip is identical to the original branch tip apart from develop moving forward (CHANGELOG.md).🤖 Generated with Claude Code
https://claude.ai/code/session_01SiHVoVCzGPCAFKe3smSge2