Repository navigation
fix(binding-mqtt-kafka): set retain on retained replay and on live delivery as the spec requires - #3161
Merged
jfallows merged 3 commits intoNov 12, 2026
Conversation
…e delivery of retained publishes Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoUCdAYMdhVqQ68F7yT
…livery as the spec requires Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoUCdAYMdhVqQ68F7yT
…hes in the kafka scripts Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoUCdAYMdhVqQ68F7yT
jfallows
force-pushed
the
fix/3152-mqtt-kafka-retain-flag
branch
from
November 12, 2026 22:51
23dab5c to
baee166
Compare
jfallows
changed the base branch from
fix/3133-mqtt-v4-clean-session-persistence
to
fix/3153-mqtt-kafka-retained-replay-conditions
November 12, 2026 22:51
This was referenced Nov 12, 2026
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
The RETAIN bit on PUBLISH packets sent to a subscriber did not follow the spec:
NoSuchElementException.What changed (design as posted on #3152):
MqttKafkaSubscribeFactory. Replay always sets RETAIN. Live delivery sets RETAIN when the publisher's RETAIN bit AND the matching filter's Retain As Published are both set. v3.1.1 live stays RETAIN=0 because that version has no RAP.zilla:retainheader on the messages-topic record (MqttKafkaHeaderHelper, written byMqttKafkaPublishFactorynext to the otherzilla:*headers). Records without the header (older versions) are treated as not retained for live delivery, as today. Existing records are not rewritten.MqttServerFactoryno longer looks up RAP or strips RETAIN. It encodes the flags it is given, which removes the lookup bugs rather than patching them.Fixes #3152
This PR is based on #3159's branch (
fix/3153-mqtt-kafka-retained-replay-conditions), which is stacked on #3160 anddevelop. It will be retargeted todevelopafter the PRs below it merge.Mqtt-to-mqtt proxy pipelines
MqttClientFactorycopies the RETAIN bit of each PUBLISH received from the upstream broker into the application Data extension flags, and forwards the downstream subscription's Retain As Published option to the broker. So the broker applies Retain As Published and the replay rule, and the MQTT server now forwards that RETAIN bit verbatim. Before this change the server removed RETAIN from every PUBLISH unless a non-generated subscription id matched a Retain As Published filter, which also removed RETAIN from broker replays. None of the mqtt example configs (mqtt.proxy.jwt,asyncapi.mqtt.proxy,mqtt.kafka.proxy,asyncapi.mqtt.kafka.proxy) use retain. No client-binding IT was run for this.Test evidence
Test-first: the first commit holds the scripts and ITs only. Against the unchanged production code (that commit on top of #3159's head),
MqttKafkaSubscribeProxyIThad 6 failures and 1 error (one test failed on both of its two runs: replay without RETAIN, live retained publish with RAP, two filters in one SUBSCRIBE, deferred filter change, resubscribe),MqttKafkaPublishProxyIThad 1 failure (zilla:retainheader), and binding-mqtt v5SubscribeIT.shouldReceiveRetainedAsPublishedfailed. The spec peer-to-peer ITs passed, so the scripts agree with each other.After the fix, every module run with
clean verify, checkstyle, license and notice checks on, build cache disabled, upstream modules installed with-am:specs/binding-mqtt.spec: 460 ITs, 0 failures, 2 skipped (+ 75 unit and schema tests, 4 skipped)specs/binding-mqtt-kafka.spec: 246 ITs + 27 unit tests, 0 failuresruntime/binding-mqtt: 380 ITs, 0 failures, 6 skipped (+ 44 unit tests)runtime/binding-mqtt-kafka: 141 ITs, 0 failures (+ 10 unit tests)Rebasing onto #3159 produced no textual conflicts. #3159's
buildFilterConditionsand retained flush sit alongside the per-filter flags list, and nothing beyond the mechanical rebase was changed.Known intermittent failure (not distinguished from this change)
MqttKafkaSubscribeProxyIT.shouldReceiveServerSentRetainedResetfailed once in a full-class run with a bareAssertionError. Measured on the earlier base (83657f92) and on this change's head at that time (23dab5cd): the whole class, 15 runs each, alternated, build cache bypassed,trimStackTrace=false, under CPU load. The base failed 0 of 15 and the head failed 1 of 15, plus 1 failure in 3 earlier full-class runs of the head. Fisher exact p is about 0.5, so the two cannot be told apart, and I never reproduced the failure on the base. The failing stack is the engine-close synthetic reset (Target.doSyntheticReset,sequence=Long.MAX_VALUE,maximum=0) reaching theonMqttResetasserts while the mqtt reply stream is still open, which happens when the client script's own reset has not closed it first. That scenario has no data frames and its scripts are unchanged by this PR. A 400 ms delay on the retained stream's abort and reset handlers in the base did not change the test time, so that experiment is inconclusive. This is not claimed to be pre-existing or fixed.Scripts changed or added (both sides, v4 and v5):
mqtt/andkafka/:subscribe.publish.retained.retain.as.published,subscribe.publish.retained.no.retain.as.published,subscribe.publish.not.retained.retain.as.published,subscribe.publish.retained.retain.as.published.multiple.filters. The first and the last go through mqtt-kafka with the Kafka side writing real records.subscribe.retain,subscribe.filter.change.retain.resubscribe,subscribe.deferred.filter.change.retain,subscribe.retained.message.expiry.interval.reduced, and network v5subscribe.get.retained.as.published.publish.retained,publish.empty.retained.message,publish.qos2.retained,publish.retained.10know expect thezilla:retainheader.subscribe.retain.as.published.not.retained.Not delivered
Follow-ups
🤖 Generated with Claude Code
https://claude.ai/code/session_01SiHVoUCdAYMdhVqQ68F7yT