Skip to content

fix(binding-mqtt-kafka): apply qos and no local conditions to retained replay on filter change - #3159

Merged
jfallows merged 2 commits into
fix/3151-mqtt-retain-handling-1from
fix/3153-mqtt-kafka-retained-replay-conditions
Nov 12, 2026
Merged

jfallows merged 2 commits into
fix/3151-mqtt-retain-handling-1from
fix/3153-mqtt-kafka-retained-replay-conditions

Conversation

@jfallows

@jfallows jfallows commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Description

When a SUBSCRIBE adds filters to an existing session while the retained Kafka stream is still open, KafkaRetainedProxy.doKafkaFlush built its Kafka filters with only the topic headers. The begin path (newKafkaStream) also adds the NO_LOCAL condition and the per-QoS-level NOT conditions, so the flushed filters matched messages the begin path would have excluded. That breaks MQTT 5.0 [MQTT-3.8.3-3] (No Local messages MUST NOT be forwarded to the publishing connection) for retained messages published by the same client, and can deliver a retained message once per QoS-level stream.

The issue was from reading the code only, so the first commit adds a failing scenario: subscribe.filter.change.retain.no.local (mqtt and kafka sides, run by MqttIT, KafkaIT and MqttKafkaSubscribeProxyIT). It holds the retained stream open, then adds a No Local filter, and expects the flushed filters to carry headerNot zilla:local and the QoS NOTs. It failed against the existing code because the retained flush carried two bare filters.

The fix extracts the begin path's condition building into buildFilterConditions and uses it from both newKafkaStream and the retained flush, so there is one copy of the logic.

Fixes #3153

Based on #3160's branch (fix/3151-mqtt-retain-handling-1), stacked on develop. The base should be retargeted to develop after #3160 merges.

Test evidence

  • specs/binding-mqtt-kafka.spec verify: 238 ITs (MqttIT 106, KafkaIT 132) pass, 27 unit tests pass; the new scripts agree peer-to-peer.
  • runtime/binding-mqtt-kafka verify with checkstyle and license on, build cache skipped: 137 ITs pass (MqttKafkaSubscribeProxyIT 61, MqttKafkaSessionProxyIT 36, MqttKafkaPublishProxyIT 40), 10 unit tests pass.
  • Without the fix (production file restored from fix(binding-mqtt): send retained messages for retain handling 1 only on a new subscription #3160's head) the new MqttKafkaSubscribeProxyIT method fails on the retained flush filters (no conditions); with the fix it passes.

Not delivered / follow-ups

  • The messages stream's own flush path (KafkaMessagesProxy.doKafkaFlush) already applies these conditions but keeps its own copy of the same code. It could reuse buildFilterConditions; left out to keep this diff small.
  • Replay is covered for the QoS 0 stream with a QoS 1 filter; other stream and filter QoS combinations share the same helper.

🤖 Generated with Claude Code

https://claude.ai/code/session_01SiHVoUeJVyz2h4Ry96ndCG

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

mqtt-kafka: retained replay on a later SUBSCRIBE omits the per-QoS and No Local conditions

2 participants