Repository navigation
fix(binding-mqtt-kafka): report retained as unsupported when the retained topic is not compacted - #3162
Merged
jfallows merged 5 commits intoNov 12, 2026
Conversation
Add the retained topic describe stream to the session scripts, a scenario for a non compacted retained topic raising the event once across two connections, and binding-mqtt scripts for retained unavailable on v4 and v5. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoV3XVVvSgjE1orC2Yk
…signal stream Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoV3XVVvSgjE1orC2Yk
…ssion is opened Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoV3XVVvSgjE1orC2Yk
…ined topic is not compacted Read cleanup.policy of the retained topic with a describe stream before the session is established, remember the result per binding and drop the retain capability and raise an event when the topic is not compacted. The mqtt server clears send retained on subscribe filters when retain is unavailable and no longer writes a CONNACK reason code outside the MQTT 3.1.1 range for a will with retain. Fixes #3158 Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoV3XVVvSgjE1orC2Yk
… before session established scripts Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoV3XVVvSgjE1orC2Yk
jfallows
force-pushed
the
fix/3158-mqtt-kafka-retained-topic-compaction
branch
from
November 12, 2026 23:10
7084d0f to
719d335
Compare
jfallows
changed the base branch from
fix/3133-mqtt-v4-clean-session-persistence
to
fix/3152-mqtt-kafka-retain-flag
November 12, 2026 23:11
This was referenced Nov 12, 2026
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
Retained messages rely on log compaction of the retained topic.
mqtt-kafkaonly checked compaction of the sessions topic, so with a non compacted retained topic retained messages silently misbehaved (several replayed messages per topic, tombstones with no effect).Now, before a session is established,
mqtt-kafkareadscleanup.policyof the retained topic with a Kafka describe stream and remembers the result in the binding config (a named capability mask,0until read). The decision is made in one place, the capability mask in the session BEGIN extension, and everything else follows from it per connection:RETAINand the eventbinding.mqtt.kafka.non.compact.retained.topicis raised.cleanup.policy=compactin the describe reply): treated like the sessions topic check, as not compacted. If the describe stream itself aborts or is reset, the connection is aborted/reset like the meta streams and nothing is remembered, so the next connection retries.binding-mqttchanges: SUBSCRIBE filters no longer carry send-retained when the session reported retain unavailable (v4 and v5), so no retained stream is opened; and a v4 CONNECT with will retain no longer writes a CONNACK return code 0x9A (outside the 3.1.1 range, previously a malformed CONNACK), it closes the connection like the retained PUBLISH path does. The publish factory's own retain handling already derives from the publish begin flags the server sets from the same capability, and a will with retain is refused at CONNECT, so no path writes a retained record when the capability is off.Event is raised once per worker: each engine worker reads the setting the first time a session connects and remembers it, so with several workers there can be one event per worker, never one per connection. Exactly once across workers would need shared state on the engine level binding, which was deliberately not done.
Based on #3161's branch (
fix/3152-mqtt-kafka-retain-flag), stacked on #3159, #3160 and develop; to be retargeted to develop after the PRs below it merge.Design discussion: #3158 (comment) (decisions on "once" per worker and the 3.1.1 model were taken in the parent discussion and are recorded here).
Fixes #3158
Test evidence
Test first: the spec scripts were committed first and run against the unchanged production code (re-confirmed after the rebase onto #3161's head).
runtime/binding-mqtt-kafkaMqttKafkaSessionProxyIT: 37 run, 29 errors (the proxy never opened the describe stream the scripts expect).runtime/binding-mqttConnectionITandSubscribeIT(v4 and v5): the new v4/v5 subscribe scenarios failed (send retained still set) and the new v4 will-with-retain scenario failed (a CONNACK 0x9A was written); the new v4 retained PUBLISH scenario already passed.After the change,
verifywith checkstyle and license, upstream modules installed, build cache bypassed (-Dmaven.build.cache.skipCache=true):specs/binding-mqtt.spec: 465 tests, 0 failures, 2 skippedspecs/binding-mqtt-kafka.spec: 248 tests, 0 failuresruntime/binding-mqtt: 384 tests, 0 failures, 6 skipped (existing skips)runtime/binding-mqtt-kafka: 142 ITs + 10 unit tests, 0 failuresNew scenarios:
session.retained.topic.not.compacted(mqtt-kafka, two connections and the event once),subscribe.retained.not.supported(v4 and v5),publish.reject.retain.not.supportedandconnect.reject.will.retain.not.supported(v4). The compacted case is covered by the retained describe stream added to the existing session scripts (which also needed the describe inserted after the will signal stream where the signal stream is opened first).Not delivered / follow-ups
binding.mqtt.kafka.non.compact.retained.topic("The retained topic (%s) is not log compacted, retained messages are not supported. Update the cleanup policy to enable log compaction."); that repository was not edited.🤖 Generated with Claude Code
https://claude.ai/code/session_01SiHVoV3XVVvSgjE1orC2Yk