Before you call an HTTP SDK to send and subscribe to messages, create resources in the Message Queue for Apache RocketMQconsole.
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.
- Log on to the .
- In the top navigation bar, select a region, such as China (Hangzhou).
- In the left-side navigation pane, click Instances.
- On the Instances page, click .
- In the Create Instance dialog box, set Instance Type, Instance Name, and Description, and click OK.
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
- 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.
- On the details page of the target instance, choose from the left-side navigation pane.
- In the Create Topic dialog box, set Topic, select Normal Message for Message Type, enter Description, and click OK.
For more information about message types, see Message types.After the topic is created, it appears in the topic list.
Create a group ID
- 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.
- On the details page of the target instance, click Groups in the left-side navigation pane.
- On the Groups page, choose .
- In the Create Group ID dialog box, set Group ID and Description, and click OK.
After the group ID is created, it appears in the group ID list.
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.
- On the details page of the target instance, click Instance Details in the left-side navigation pane.
- 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.
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.