[feat][mqtt] Support dynamic MQTT topic via topicProperty config#34
Open
Dream95 wants to merge 1 commit into
Open
[feat][mqtt] Support dynamic MQTT topic via topicProperty config#34Dream95 wants to merge 1 commit into
Dream95 wants to merge 1 commit into
Conversation
Signed-off-by: Dream95 <zhou_8621@163.com>
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.
Motivation
In MQTT IoT setups, messages are often routed per device to topics like /data/{deviceId} or sensor/{deviceId}/telemetry. Each device may need its own MQTT topic instead of a single shared one.
MqttSink only supports a fixed topic in configuration today, so it cannot choose the destination topic per message from device identity.
Solution
Add an optional topicProperty setting to MqttSink. It names the Pulsar message property that holds the target MQTT topic.
When topicProperty is set, the sink reads that key from record.getProperties() and uses the value as the publish topic. If topicProperty is unset, or the property is missing or blank on a message, the sink uses the configured topic. Existing configs that only set the topic behave the same as before.