Before you call an SDK to send and receive messages in HTTP mode, create 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 the 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, for example, China (Hangzhou).
  4. On the Instances page, click Create Instance.
  5. In the Create Message Queue for Apache RocketMQ Instance dialog box, select an Instance Type, enter an Instance Name and Description, and then click OK.
    create_instance

    For information about the billing of Message Queue for Apache RocketMQ Standard Edition and 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. The message producers send messages to Topic_Trade and the message consumers subscribe to Topic_Trade to consume the messages.
  • 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 common messages, Topic B for transactional messages, and Topic C for scheduled and delayed messages.
  1. On the instance details page, click Topics in the left-side navigation pane.
  2. On the Topics page, click Create Topic.
  3. In the Create Topic dialog box, enter a name and Description, set the Message Type to Common Message, and then click OK.
    create_topic
    Note This topic uses common messages as an example. You can use the preceding procedure to create a topic that processes common messages. The topic you created cannot be used to send or receive other types of messages. Each topic can send and receive messages of a specified type. For more information, see Message types.
    The created topic is displayed 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 Instance Details page, click Groups in the left-side navigation pane.
  2. In the Groups page, choose TCP > Create Group ID.
  3. In the Create Group ID dialog box, enter a Group ID and Description, and then click OK.
    create_http_group_id
    The created group ID is displayed 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 Instance Details page, click Instance Details in the left-side navigation pane.
  2. In the HTTP Client Endpoint section of the Instance Details page, move the pointer over the endpoint and click the endpoint. Then, the endpoint is copied and available for subsequent use.
    obtain_http_endpoint

    The HTTP endpoints displayed in the console are the endpoints of a region, instead of a specific instance. You must specify the instance ID when you send and subscribe to messages.

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

What to do next

Call HTTP SDKs to send and subscribe to normal messages