Before you call an HTTP client SDK to send and subscribe to messages, you must create required resources in the Message Queue for Apache RocketMQ console.

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

An instance is a virtual machine (VM) resource of Message Queue for Apache RocketMQ. An instance stores topics and group IDs.

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

    For more information about the billing of Message Queue for Apache RocketMQ Standard Edition and Enterprise Platinum Edition instances, see Billing overview.

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

Create a topic

A topic is a first-level identifier that is used to classify messages in Message Queue for Apache RocketMQ. For example, you can create a topic named Topic_Trade for transactional messages. Message producers send messages to Topic_Trade and message consumers subscribe to Topic_Trade to consume the messages. Topics must meet the following requirements:
  • A topic cannot be used across instances. For example, Topic A created in Instance A is unavailable in Instance B.
  • Each topic name must be unique in an instance.
  • We recommend that you create different topics to send different types of messages. For example, you can create Topic A for normal messages, Topic B for transactional messages, and Topic C for scheduled and delayed messages.
  1. On the page of the instance, click Topics in the left-side navigation pane.
  2. On the Topics page, click Create Topic.
  3. In the Create Topic panel, set Name and Description, set Message Type to Normal Message, and then click OK.
    create_topic
    Note This topic describes how to send and subscribe to normal messages. Therefore, the topic that you create for normal messages by using the preceding procedure cannot be used to send or subscribe to other types of messages. Each topic can be used to send and subscribe to messages of a specified type. For more information, see Message types.
    The created topic appears in the topic list.

Create a group ID

After you create an instance and a topic, you must create a group ID for the message consumer or producer. Group IDs must meet the following requirements:
  • Each group ID must be unique in an instance.
  • Group IDs have an N:N relationship with topics. 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 page of the instance, click Groups in the left-side navigation pane.
  2. On the Groups page, choose HTTP > Create Group ID.
  3. In the Create Group for HTTP Protocol panel, set Group ID and Description, and then click OK.
    create_http_group_id
    The created group ID appears in the group ID list.

Obtain an endpoint

After you create an instance in the console, you must obtain an endpoint of the instance in the Message Queue for Apache RocketMQ console. To send and subscribe to messages, you must configure the endpoint for the producer and consumer. Then, the producer and consumer can access services in the corresponding instance or region.

  1. On the page of the instance, click Instance Details in the left-side navigation pane.
  2. On the Instance Details page, click the Endpoints tab.
  3. In the HTTP Endpoint section, move the pointer over the endpoint and click the endpoint to copy it.
    http_endpoint

    The HTTP endpoint displayed in the console is the endpoint of a region, instead of a specific instance. You must configure an ID for the instance when you send and subscribe to messages.

    Note The HTTP endpoint and TCP endpoint of the same instance cannot be interchangeably used.

After you complete the preceding operations, you can run the sample code and use Message Queue for Apache RocketMQ to send and subscribe to messages.

What to do next

Call HTTP client SDKs to send and subscribe to normal messages