Repository navigation
Expose MQTT publish metadata to custom payload formatters - #18628
Hanabi9248 wants to merge 3 commits into
Conversation
Signed-off-by: Hanabi <317387557+Hanabi9248@users.noreply.github.com>
Signed-off-by: Hanabi <317387557+Hanabi9248@users.noreply.github.com>
Signed-off-by: Hanabi <317387557+Hanabi9248@users.noreply.github.com>
There was a problem hiding this comment.
🟢 Approval recommended
The implementation is backward-compatible, documented, and adequately tests payload lifecycle and dispatch behavior.
Pull request overview
Exposes MQTT publication metadata to custom payload formatters while preserving backward compatibility.
Changes:
- Adds a metadata-aware formatter callback.
- Passes full publications through the handler.
- Documents and tests dispatch and payload ownership.
File summaries
| File | Description |
|---|---|
PayloadFormatter.java |
Adds the backward-compatible callback. |
MPPPublishHandler.java |
Dispatches complete publications. |
PayloadFormatterContextTest.java |
Tests delegation, dispatch, and release behavior. |
README.md |
Documents metadata access and payload lifetime. |
Review details
- Files reviewed: 4/4 changed files
- Comments generated: 0
- Review effort level: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
Could a committer review the metadata-aware MQTT formatter callback for #18625 at The new The current head has 37 successful check runs and two skipped Sonar/Codecov checks, with no failed or pending check runs. The PR description records the focused 11-test MQTT run; I have not rerun tests for this follow-up. Please let me know if the callback contract or compatibility behavior needs adjustment. |
Description
Fixes #18625.
Pass the complete MQTT publication to custom payload formatters so they can use the client ID, username and QoS alongside the topic and payload.
The new
formatMessage(InterceptPublishMessage)default method delegates toformat(String, ByteBuf), which retains the existing payload-only fallback. Existing formatters need no changes. A separate method name also avoids making existingformat(null)calls ambiguous. The broker still owns and releases the payload; the customization guide documents its lifetime.Tests
On JDK 25, the 30-module Maven reactor build and all 11 MQTT tests passed:
mvn -pl external-service-impl/mqtt -am test \ -Dtest=PayloadFormatterContextTest,JSONPayloadFormatterTest,LinePayloadFormatterTest \ -Dsurefire.failIfNoSpecifiedTests=falseThe new tests cover payload-only and topic-aware formatters, handler dispatch, and payload release when a formatter returns or throws. Both handler tests fail when run against the old handler. Cluster integration tests were not run.