konlue opened a new pull request, #7938:
URL: https://github.com/apache/shenyu/pull/7938
Fixes #7919.
## Summary
An inbound QoS 2 `PUBLISH` was always fanned out to subscribers and only
answered with `PUBREC` — no receiving-side state was kept. A client
retransmitting the same packet id before its `PUBREL` (e.g. after a slow
`PUBREC`) therefore got the message delivered to subscribers a second time
under a freshly allocated packet id, breaking exactly-once.
## Modifications
- New `InflightRepository` (`BaseRepository`, so `MqttBootstrapServer`
registers it with the other repositories): per-client set of inbound packet ids
currently in the acknowledgement flow.
- `Publish` now registers the packet id before delivery; only a first-seen
packet id is fanned out, and every QoS 2 publish (first or retransmitted) is
answered with `PUBREC`. QoS 0/1 paths are unchanged, and an unknown client (no
CONNECT handshake seen) keeps the previous behavior.
- `PubRel` releases the packet id when `PUBCOMP` is sent, so the id becomes
reusable; a `PUBREL` for an unknown packet id still gets `PUBCOMP`, per spec.
- `Disconnect.cleanChannel` discards the in-flight state together with the
session on a clean-session disconnect; a persistent session keeps it across
reconnects, matching the session-present resumption semantics.
## Verifying this change
- [x] `testQos2RetransmitIsPublishedExactlyOnce`: packet id 77 delivered
once; the DUP retransmission is answered with `PUBREC` and the subscriber still
sees exactly one publication. Fails on the previous code (two deliveries).
- [x] `testPubRelReleasesInflightForRedelivery`: `PUBREL` → `PUBCOMP`, and
the same packet id may be delivered again afterwards.
- [x] `testPubRelForUnknownPacketIdStillRespondsWithPubComp`.
- [x] Full module tests and Checkstyle pass:
```bash
./mvnw -pl shenyu-protocol/shenyu-protocol-mqtt checkstyle:check
```
132/132 green, checkstyle clean.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]