Adding an MQTT Publish Prefix
Configure a per-user topic prefix that Connectware adds to every MQTT message the user publishes.
A publish prefix is a fixed topic fragment that Connectware prepends to every MQTT message a user publishes. Because you set it per user, different users can route their data to different destinations without changing the topics they publish to.
For example, if UserA has the prefix topicA/ and publishes a message to some/values, Connectware delivers it on topicA/some/values.
Mapping resources can achieve the same routing, but each mapping adds an MQTT message transfer that a prefix avoids. This makes prefixes a good fit for high-throughput installations that need fast MQTT delivery.
Admin UI Configuration
To add an MQTT prefix to an existing user in the Admin UI, edit the MQTT Publish Prefix field in the Edit User dialog.
Toggle the Advanced mode switch in the top right of the dialog. This extends the dialog with an Additional permissions section.


Edit the MQTT Publish Prefix field.

In the Additional permissions section, add an MQTT write permission for each topic the user publishes to, including the prefix. For example, if the prefix is
topicA/and the user publishes tosome/values, add write permission fortopicA/some/values. To omit the prefix from the permission, use an MQTT wildcard as a placeholder, for example+/some/values.
Example
This example sets up and validates a publish prefix for the user newuser:
Add the MQTT prefix
route-to-downstream/using the Edit User dialog as described above.Add an MQTT write permission for the topic
route-to-downstream/my-topic(that is, including the prefix) for this user in the user management.
To confirm that the setting works as expected, send an MQTT message with an MQTT client, such as the mosquitto_sub and mosquitto_pub command-line tools. Install these tools before you continue.
Subscribe to the topic
route-to-downstream/my-topicwith the following command:
Replace ${ADMIN_PASSWORD} with the password of the admin user.
Publish a message to the topic
my-topicwith the following command:
Replace ${NEW_USER_PASSWORD} with the password of the newuser user.
The subscribed client receives the published message Hello World on the prefixed topic route-to-downstream/my-topic.
Last updated
Was this helpful?

