Before you use a TCP client SDK to send and subscribe to messages, create the required resources in the Message Queue for Apache RocketMQ console. You must configure the resource parameters before you call the SDK.
Background information
Message Queue for Apache RocketMQ provides client SDKs for multiple programming languages. Different SDKs are provided to send or subscribe to messages over different protocols, including TCP and HTTP. We recommend that you create different group IDs for different protocols. For more information about the limits on using groups for each protocol, see Group management.
Network access limits
Before you use Message Queue for Apache RocketMQ, take note of the following network access limits:
- A topic can be accessed by a producer or a consumer only if the group of the producer or consumer and the topic are created on the same instance. For example, if a topic is created on Instance A in the China (Hangzhou) region, the topic can be accessed only by a producer or consumer whose group is created on Instance A in the China (Hangzhou) region.
- If you use a local server and want to connect to Message Queue for Apache RocketMQ over the Internet, you must create a topic and a group on an instance in the Internet region.
Producer and consumer clients can be deployed on a local server or an Elastic Compute Service (ECS) instance that can access the Internet.
For more information about regions, see Regions and zones.
Create an instance
An instance is a virtual machine that provides the Message Queue for Apache RocketMQ service. An instance stores topics and group IDs.
Create a topic
- A topic cannot be used across instances. For example, Topic A that is 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.
Create a group ID
- Each group can be used in only one instance. For example, a group that is created in Instance A cannot be used in Instance B.
- In Message Queue for Apache RocketMQ, consumer groups can consume messages over HTTP or TCP. Different consumer groups
can use different protocols. We recommend that you create a group for each protocol.
- If multiple consumers with the same group ID use different protocols, message consumption may fail, and message duplication and message loss may occur.
- Approximately 1 to 2 hours is required to change the protocol that is used by the consumers in a group.
- If the consumers in a group consume messages by using a protocol that is different from the protocol that is displayed in the console, the data that is displayed in the console can be inaccurate. This does not affect messaging of the group. You can submit a ticket to change the protocol that is displayed in the console to the protocol that is being used.
- A group ID must be specified for each consumer. You do not need to specify a group ID for each producer.
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 or subscribe to messages, configure the endpoint on the producer or consumer to allow the producer or consumer to access the instance in a specific region.
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.