All Products
Search
Document Center

ApsaraMQ for MQTT:Create resources

Last Updated:Dec 06, 2023

Before you use ApsaraMQ for MQTT SDKs to send and receive messages, you must create related resources, such as instances, topics, and groups, in the ApsaraMQ for MQTT console. When you use ApsaraMQ for MQTT SDKs to send and receive messages, you must specify the information about these resources in the code.

Before you start

Activate ApsaraMQ for MQTT and authorize a RAM user to access ApsaraMQ for MQTT resources

Create an instance and obtain an endpoint of the instance

In ApsaraMQ for MQTT, an instance is a virtual machine that is used to store information related to topics and groups.

  1. Log on to the ApsaraMQ for MQTT console. In the left-side navigation pane, click Instances.

  2. In the top navigation bar, select the region where the instance that you want to manage resides. Then, in the upper-left corner, click Create Instance.

  3. In the panel that appears, use the default value Subscription for the Billing Method parameter. Then, Click OK.

  4. On the buy page that appears, select the instance specifications that you want to purchase based on your business requirements, select the terms of service, and then click Buy Now.

    For information about the instance editions provided by ApsaraMQ for MQTT and their feature differences, see Instance editions.

  5. On the order payment page, follow the on-screen instructions to complete the payment.

  6. After you complete the payment, click Console on the page that appears.

  7. Go back to the ApsaraMQ for MQTT console. In the left-side navigation pane, click Instances. In the top navigation bar, select the region in which your instance is deployed.

  8. On the Instances page, click the name of the instance or click Details in the Actions column of the instance to go to the Instance Details page.

  9. On the Instance Details page, click the Endpoints tab. On the tab, you can view the endpoint information. In the example, the public endpoint is used.

    Endpoint

Create a topic

The MQTT protocol supports multi-level topics. You must create a parent topic in the ApsaraMQ for MQTT console. You can specify subtopics in the code without the need to create them in the console. A parent topic and its subtopics are named in the following format: <Name of a parent topic>/<Name of a level-2 topic>/<Name of a level-3 topic>. A parent topic and its subtopics are separated by forward slashes (/). Example: SendMessage/demo/producer. The total length of the names of a parent topic and its subtopics cannot exceed 64 characters. For more information about topics, see Terms.

  1. Log on to the ApsaraMQ for MQTT console. In the left-side navigation pane, click Instances.

  2. In the top navigation bar, select the region where the instance that you want to manage resides. On the Instances page, click the instance name to go to the Instance Details page.

  3. In the left-side navigation pane, click Topics. In the upper-left corner of the Topics page, click Create Topic.
  4. In the Create Topic panel, set the Name and Description parameters for the topic and click OK in the lower-left corner.

Create a group

For more information about group IDs, see Terms.

  1. Log on to the ApsaraMQ for MQTT console. In the left-side navigation pane, click Instances.

  2. In the top navigation bar, select the region where the instance that you want to manage resides. On the Instances page, click the instance name to go to the Instance Details page.

  3. In the left-side navigation pane, click Groups. In the upper-left corner of the Groups page, click Create Group.
  4. In the Create Group panel, set the Group ID parameter and click OK.

What to do next