Before you use Message Queue for MQTT SDKs to send and receive messages, you must create related resources, such as instances, topics, and groups, in the Message Queue for MQTT console. The information of these resources is required when you use Message Queue for MQTT SDKs.

Create an instance and obtain an endpoint of the instance

An instance is a VM of Message Queue for MQTT. An instance stores topics and group IDs.

  1. Log on to the Message Queue for MQTT console.
  2. In the left-side navigation pane, click Instances.
  3. In the top navigation bar, select a region.
  4. On the Instances page, click Create Instance in the upper-left corner.
  5. In the panel that appears, select a billing method as needed.
    Message Queue for MQTT supports the Pay-as-you-go and Subscription billing methods. For more information about the two billing methods, see Billing.
    • Create a pay-as-you-go instance:
      1. Set Billing Method to Pay-as-you-go and click OK.
      2. In the panel that appears, set the parameters as needed and click Buy Now.
    • Create a subscription instance:
      1. Set Billing Method to Subscription and click OK.
      2. In the panel that appears, set the parameters as needed and click Buy Now.
      3. In the panel that appears, click Purchase.
    After you complete the purchase, refresh the Instances page in the Message Queue for MQTT console. The instance that you created appears in the instance list.
  6. On the Instances page, click the name of the instance that you purchased or click Details in the Actions column to go to the Instance Details page.
  7. On the Instance Details page, click the Endpoints tab. On this tab, you can view the endpoint information. In the example, the public endpoint is used.

Create a topic

The MQTT protocol supports multi-level topics. You must create a parent topic in the Message Queue for MQTT console or by calling an API operation. You do not need to create a subtopic. For more information about topics, see Terms. In this example, a parent topic is created in the Message Queue for MQTT console.

  1. Log on to the Message Queue for MQTT console.
  2. In the left-side navigation pane, click Instances.
  3. In the top navigation bar, select a region.
  4. Find the instance for which you want to create a topic in the instance list. In the Actions column, choose More > Topics.
  5. In the upper-left corner of the Topics page, click Create Topic.
  6. In the Create Topic panel, set the Name and Description parameters for the topic and click OK in the lower-left corner.
    You can view the topic that you create on the Topics page.

Step 3: Create a group ID

For more information about group IDs, see Terms.

  1. Log on to the Message Queue for MQTT console.
  2. In the left-side navigation pane, click Instances.
  3. In the top navigation bar, select a region.
  4. Find the instance for which you want to create a group ID in the instance list. In the Actions column, choose More > Groups.
  5. In the upper-left corner of the Groups page, click Create Group.
  6. In the Create Group panel, set the Group ID parameter and click OK.
    You can view the created group ID on the Groups page.

What to do next

Use Message Queue for MQTT SDK for Java to implement messaging between Message Queue for MQTT clients