Before you call an HTTP SDK to send and subscribe to messages, create resources in the Message Queue for Apache RocketMQconsole.

Background information

Message Queue for Apache RocketMQ provides SDKs for multiple programming languages to send and subscribe to messages over TCP and HTTP. To use Message Queue for Apache RocketMQ, you must create an instance, a topic, and a group ID. Due to client differences, a group ID cannot be used for both TCP clients and HTTP clients. Therefore, you must create group IDs for TCP clients and HTTP clients separately.

Create an instance

As a virtual machine (VM) resource of Message Queue for Apache RocketMQ, an instance stores the topics and group IDs of messages.

  1. Log on to the Message Queue for Apache RocketMQ console.
  2. In the top navigation bar, select a region, such as China (Hangzhou).
  3. In the left-side navigation pane, click Instances.
  4. On the Instances page, click create_icon.
  5. In the Create Instance dialog box, set Instance Type, Instance Name, and Description, and click OK.
    create-instance

    For more information about the billing of Standard Edition and Platinum Edition instances, see t1841146.html#section_6xq_63o_qv3.

    After the instance is created, it appears on the Instances page.

Create a topic

A topic is the first-level identifier for classifying messages in Message Queue for Apache RocketMQ. For example, you can create a topic named Topic_Trade for transactional messages. The message producer sends messages to Topic_Trade and the message consumer subscribes to Topic_Trade to consume messages.
  • Topics cannot be used across instances. For example, Topic A created in Instance A cannot be used in Instance B.
  • A topic name must be unique within an instance.
  • We recommend that you create different topics to send different types of messages. For example, create Topic A for normal messages, Topic B for transactional messages, and Topic C for scheduled and delayed messages.
  1. On the details page of the target instance, choose Topics > Create Topic from the left-side navigation pane.
  2. In the Create Topic dialog box, set Topic, select Normal Message for Message Type, enter Description, and click OK.
    create-topicFor more information about message types, see Message types.
    After the topic is created, it appears in the topic list.

Create a group ID

After you have created an instance and a topic, you need to create a group ID for the message consumer or producer.
  • A group ID must be unique within an instance.
  • Group IDs and topics implement N:N mapping. A consumer can subscribe to multiple topics and a topic can be subscribed to by multiple consumers. A producer can send messages to multiple topics and a topic can receive messages from multiple producers.
Note A group ID is required for consumers but is optional for producers.
  1. On the details page of the target instance, click Groups in the left-side navigation pane.
  2. On the Groups page, choose HTTP > Create Group ID.
  3. In the Create Group ID dialog box, set Group ID and Description, and click OK.
    create-GID
    After the group ID is created, it appears in the group ID list.

Obtain endpoints

After creating resources in the console, you need to obtain the endpoint of the instance in the console. To access services in an instance or a region when sending or subscribing to messages, you need to configure the endpoints for the producer and consumer.

  1. On the details page of the target instance, click Instance Details in the left-side navigation pane.
  2. On the Instance Information tab that appears by default, go to the HTTP Endpoint section and click the endpoint of the target HTTP client to copy it.
    HTTP-endpoint

    The HTTP endpoint displayed in the console is the endpoint of a region, instead of a specific instance. You need to configure an ID for the instance when sending and subscribing to messages.

    Note HTTP and TCP endpoints cannot be used interchangeably.

What to do next

Call HTTP SDKs to send and subscribe to normal messages