Repository navigation
Allow MQTTHandlers to replace other MQTTHandlers - #3656
richturner wants to merge 6 commits into
Conversation
Adds `MQTTHandler.getReplacedHandlers()` so a custom project can take over the topic of a built-in handler (e.g. `UserAssetProvisioningMQTTHandler`). A handler that extends another loaded handler replaces it implicitly. Replaced handlers are discarded on load, so they are never initialized or started and never consume messages; ordering by priority alone was not enough because every handler receives published messages on its topics.
stop() reloaded the handlers via ServiceLoader, so it stopped new instances that were never initialized instead of the running ones, and ignored replaced handlers. It now stops the loaded handlers in reverse priority order.
|
Validated this in a custom project and it works |
ebariaux
left a comment
There was a problem hiding this comment.
Other codex findings
- [P2] Test which handler instances receive lifecycle callbacks — manager/src/main/java/org/openremote/manager/mqtt/MQTTBrokerService.java:462-463
X509ProvisioningProofTest constructs its handler directly, so it would still pass if the broker initialized a replaced provider or reverted to stopping freshly loaded instances. Add a Spock unit spec in manager/src/test/groovy with a replacement and an unrelated peer; assert that only the selected instances initialize and start, and that those same instances stop once in reverse order.
And you did not revert the change on the challenge, so this still needs to be indicated as a breaking change for this release.
|
Changes made based on the review; prefix revert means the PR no longer needs the Breaking Change label. |
|



This PR introduces
MQTTHandler.getReplacedHandlers()to allow one MQTTHandler to replace one or more other MQTTHandler(s) by class name.This is an alternative approach to #3590 which this PR also reverts.