NIFI-16203 Support multiple Topic Filters in ConsumeMQTT - #11556
Open
drewyh999 wants to merge 1 commit into
Open
NIFI-16203 Support multiple Topic Filters in ConsumeMQTT#11556drewyh999 wants to merge 1 commit into
drewyh999 wants to merge 1 commit into
Conversation
ConsumeMQTT exposed a single Topic Filter and issued one subscription per connection, so consuming N topics required N processor instances, each opening its own broker connection with its own Client ID. Wildcards are unusable when topic names are flat or externally dictated, or when broker ACLs only authorize explicit topics. The MQTT SUBSCRIBE packet natively carries a list of (Topic Filter, QoS) pairs on every protocol version NiFi supports, so the Topic Filter property now accepts a comma separated list and all filters are subscribed to with a single SUBSCRIBE request over one connection. The property is not renamed and a value without a comma is a single Topic Filter used verbatim, so existing flows are unaffected and no property migration is needed. Additionally, the SUBACK response was only logged, so a filter rejected by the broker failed silently while the processor still looked healthy. Both adapters now inspect the per filter response, HiveMQ through the SUBACK reason codes and Paho through the granted QoS array, and fail with the offending topic filter listed. Since a SUBSCRIBE listing several filters can be granted partially, a failure can leave the client connected and subscribed, so it is now disconnected and closed rather than only being dereferenced, which previously leaked the connection and let the orphaned client keep feeding the internal queue. - Add MqttTopicSubscription and change MqttClient.subscribe to take a list - Apply the shared subscription prefix to each filter individually - Reject blank and duplicate Topic Filters during validation - Report every subscribed topic filter in the aggregated provenance URI - Trim only the entries of a comma separated value, as leading and trailing whitespace is significant in an MQTT Topic Filter - Stop the HiveMQ adapter from re-wrapping its own rejection exception, which hid the rejected topic filter behind a generic message Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
drewyh999
force-pushed
the
nifi-16203-consumemqtt-multiple-topic-filters
branch
from
August 17, 2026 09:10
645c781 to
42231dd
Compare
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.
Summary
NIFI-16203
ConsumeMQTTexposes a singleTopic Filterproperty and issues one subscription per connection, so consuming from N topics requires N Processor instances, each opening its own broker connection with its own Client ID. A wildcard filter is the usual workaround, but it is unusable when topic names are flat or externally dictated, or when broker ACLs authorise only explicit topics.The MQTT SUBSCRIBE packet natively carries a list of (Topic Filter, QoS) pairs on every protocol version NiFi supports, so
Topic Filternow accepts a comma separated list and every filter is subscribed to with a single SUBSCRIBE request over one connection.Backward compatibility
The property is not renamed and a value containing no comma is treated as a single Topic Filter and used verbatim, so existing flows are unaffected and no property migration is needed. Only the entries of a comma separated value are trimmed, since leading and trailing whitespace is significant in an MQTT Topic Filter.
Because MQTT Topic Filters may legally contain a comma, a filter that itself contains one is interpreted as multiple filters. This is called out in both the property description and
additionalDetails.md.SUBACK handling
While implementing this it became apparent that the SUBACK response was only logged, so a Topic Filter rejected by the broker (for example due to an ACL denial) failed silently while the Processor still looked healthy. This matters more with multiple filters, since a SUBSCRIBE listing several filters can be granted partially. Both adapters now inspect the per filter response — HiveMQ through the SUBACK reason codes, Paho through the granted QoS array — and fail with the offending Topic Filter listed.
Since a partial grant leaves the client connected and subscribed, a failure now disconnects and closes it rather than only dropping the reference, which previously leaked the broker connection and left an orphaned client feeding the internal queue.
Changes
MqttTopicSubscriptionand changeMqttClient.subscribeto take a list$share/<Group ID>/) to each filter individuallyTracking
Please complete the following tracking steps prior to pull request creation.
Issue Tracking
Pull Request Tracking
NIFI-00000NIFI-00000VerifiedstatusPull Request Formatting
mainbranchVerification
Please indicate the verification steps performed prior to pull request creation.
Build
./mvnw clean install -P contrib-checkVerified on the
nifi-mqtt-processorsmodule only (JDK 21):./mvnw -pl nifi-extension-bundles/nifi-mqtt-bundle/nifi-mqtt-processors test checkstyle:check— 57 tests pass, checkstyle clean. A fullcontrib-checkbuild across both JDKs has not been run locally; happy to follow up on any CI findings.Licensing
LICENSEandNOTICEfilesNo new dependencies are introduced.
Documentation
additionalDetails.mdforConsumeMQTTgains a "Multiple Topic Filters" section, and theTopic Filterproperty description is updated.