MQTT Wildcards

Estimated reading time: 1 minute

Devices publish data to topics (e.g. Fruits/cherry/red) and subscribe to receive data from them. Wildcards allow you to subscribe devices to multiple topics that have common strings among them. Wildcard topic strings have a (+) sign or a (#) sign in them. The (+) sign allows you to choose each level within the topic. For example, subscription to a topic Fruits/+/red selects the topics:

Fruits/cherry/red

Fruits/apple/red

Fruits/strawberry/red

The (+) sign matches a single level of a topic. Use the (#) sign to subscribe to multiple levels. For example, Fruits/apple/# subscribes to data being sent on Fruits/apple as well as Fruits/apple/red.

  • Devices can only subscribe to wildcard topics. They cannot publish to them.
  • The project should have all devices deployed before subscribing the devices to wildcard topics in Workload Orchestrator.

To subscribe to wildcard topics in HPE Workload Orchestrator:

  1. In the navigation panel, click Project List.
  2. Select the project with the devices to subscribe to a wildcard topic.
  3. In the navigation panel, select Settings.
  4. Select the Credentials tab at the top of the Settings page.

  5. Scroll down to the Credentials section of the Settings page and click on Add in the top right corner of the section. Adding one allows you to access wildcard topics or custom topics

    Make sure to take note of the password when you first add new Credentials. You will not be able to access it again for security reasons.

  6. Click Close to complete adding the new credentials.

  7. Scroll to the ACL section of the Settings page and click Add.
  8. Use the drop-down menus to add the Account Name and Topics that come with the credentials that you created in steps 1-6.

    Make sure to check Subscribe when making ACLs for wildcard topics

  9. Scroll to the Topics section in the Credentials tab of the Settings page to view the syntax for your wildcard topics. You can now subscribe devices to the wildcard topics to access data in multiple topics.