Before you use an SDK to send and receive messages, you must create resources in ApsaraMQ for RocketMQ, including ApsaraMQ for RocketMQ instances, topics, and consumer groups. You must also obtain the endpoints of the instances. When you use the SDK to send and receive messages, you must specify the information about the resources in the SDK code.
Before you start
Background information
ApsaraMQ for RocketMQ allows you to create resources in the ApsaraMQ for RocketMQ console or by calling API operations. This topic describes how to create resources in the ApsaraMQ for RocketMQ console.
If you want to create resources by calling API operations, refer to the following topics:
Limits
Regions
Make sure that the ApsaraMQ for RocketMQ instance resides in the same region as the VPC and vSwitch that you created in the "Before you start" section of this topic.
Naming conventions
For information about the naming conventions of ApsaraMQ for RocketMQ instances, topics, and consumer groups, see Quotas and limits.
Message types of topics
The message type of a topic must be consistent with the type of message that the topic sends and receives. For example, if you create a topic that is used to send and receive normal messages, you can use it to send and receive only normal messages. For more information, see Usage notes.
Create an instance
Log on to the ApsaraMQ for RocketMQ console. In the left-side navigation pane, click Instances.
In the top navigation bar, select a region, such as China (Hangzhou).
On the Instances page, click Create Instance. In the Create Message Queue for Apache RocketMQ Instance panel, set the Instance Version parameter to V5.0 and configure the Billing Method parameter. Then, click OK.
ApsaraMQ for RocketMQ supports the following billing methods:
Subscription: An upfront payment is required based on the computing specification and subscription duration (in months) that you select for an instance.
Pay-as-you-go: Fees are post-paid based on the computing specification that you select for an instance and the actual usage duration (in hours) of the instance.
Serverless: You are charged based on the total number of API calls that are initiated to receive and deliver messages.
NoteServerless ApsaraMQ for RocketMQ instances are available only in the following regions: China (Hangzhou), China (Shanghai), China (Beijing), China (Zhangjiakou), China (Shenzhen), China (Chengdu), Singapore, Germany (Frankfurt), and US (Virginia).
For information about the billable items and scenarios of different billing methods, see Overview.
On the buy page, select the specifications of the instance and click Buy Now. Then, follow the on-screen instructions to complete the payment.
The following table provides an example on how to configure the parameters on the buy page. For information about the specifications that are displayed on the buy page, see Instance selection.
Parameters configured for a serverless instance
Parameter
Example
Primary Edition
Standard Edition
Billing Method
The billing method. On-demand Capacity is automatically specified.
Message Storage Capacity
The space that is used to store messages. You do not need to specify the storage capacity. You are charged for storage space based on the actual usage.
VPC ID
vpc-bp1cg09dua6sgh0******
The value of this parameter is the ID of the VPC that you created in the "Before you start" section of this topic.
ImportantAfter you create an ApsaraMQ for RocketMQ instance, you cannot change the VPC in which the instance is deployed. If you want to change the VPC in which an ApsaraMQ for RocketMQ instance is deployed, you must release the instance and purchase a new instance.
VSwitch ID
vsw-bp1vqb0p9nz3irz******
The value of this parameter is the ID of the vSwitch that you created in the "Before you start" section of this topic.
You must select two vSwitch IDs for a serverless ApsaraMQ for RocketMQ instance.
ImportantAfter you create an ApsaraMQ for RocketMQ instance, you cannot change the vSwitch with which the instance is associated. If you want to change the vSwitch with which an ApsaraMQ for RocketMQ instance is associated, you must release the instance and purchase a new instance.
Internet Access
Disable
NoteIn this example, the client is connected to the ApsaraMQ for RocketMQ broker in a VPC. By default, Internet access is disabled. If you want to access ApsaraMQ for RocketMQ over the Internet, set this parameter to Enable.
Billing Method of Internal Network Traffic
The billing method of internal network traffic. Pay-by-Data-Transfer is automatically specified.
You can access serverless ApsaraMQ for RocketMQ instances only in VPCs.
Resource Group
The resource group to which the serverless ApsaraMQ for RocketMQ instance belongs. In this example, the default resource group is selected.
Security Group
The security group that you created in the "Before you start" section of this topic.
Parameters configured for a subscription or pay-as-you-go instance
Parameter
Example
Primary Edition
Standard Edition
Sub-category Edition
Cluster High-availability Edition (Recommended for Production Environments)
Computing Specification
rmq.s2.2xlarge
VPC ID
vpc-bp1cg09dua6sgh0******
The value of this parameter is the ID of the VPC that you created in the "Before you start" section of this topic.
ImportantAfter you create an ApsaraMQ for RocketMQ instance, you cannot change the VPC with which the instance is associated. If you want to change the VPC in which an ApsaraMQ for RocketMQ instance is deployed, you must release the instance and purchase a new instance.
VSwitch ID
vsw-bp1vqb0p9nz3irz******
The value of this parameter is the ID of the vSwitch that you created in the "Before you start" section of this topic.
ImportantAfter you create an ApsaraMQ for RocketMQ instance, you cannot change the vSwitch with which the instance is associated. If you want to change the vSwitch with which an ApsaraMQ for RocketMQ instance is associated, you must release the instance and purchase a new one.
Internet Access
Disable
NoteIn this example, the client is connected to the ApsaraMQ for RocketMQ broker in a VPC. By default, Internet access is disabled. If you want to access ApsaraMQ for RocketMQ over the Internet, set this parameter to Enable.
Resource Group
The resource group to which the ApsaraMQ for RocketMQ instance belongs. In this example, the default resource group is selected.
Obtain the endpoint of an instance
On the Instances page, click the name of the instance that you want to manage.
In the TCP Endpoint section of the Instance Details page, view the endpoints of the instance.
VPC endpoint: The endpoint that is used to access the ApsaraMQ for RocketMQ instance in a VPC. This is the default endpoint provided by ApsaraMQ for RocketMQ.
Public endpoint: The endpoint that is used to access the ApsaraMQ for RocketMQ over the Internet. The public endpoint is displayed only if you enable Internet access.
Obtain the username and password of an instance
In this example, intelligent authentication is used to describe how to obtain the username and password of an ApsaraMQ for RocketMQ instance.
If you want to use access control list (ACL)-based access authentication, you must create an ACL user, grant the required permissions to the ACL user, and obtain the username and password of the ACL user. For more information, see User authentication.
When you connect a client to an ApsaraMQ for RocketMQ broker, whether to specify the username and password of the instance is determined by the access method.
If you access the ApsaraMQ for RocketMQ broker over the Internet, you must specify the username and password of the instance.
If you access the ApsaraMQ for RocketMQ broker in a VPC, you need to specify the username and password only if the instance is a serverless instance and the authentication-free in VPCs feature is disabled for the instance. In other cases, The system automatically identifies the client based on the VPC endpoint that the client uses.
On the Instances page, click the name of the instance that you want to manage.
In the left-side navigation pane of the page that appears, click Access Control.
Click the Intelligent Authentication tab to view the username and password of the instance.
Create a topic
On the Instances page, click the name of the instance that you want to manage.
In the left-side navigation pane, click Topics. On the Topics page, click Create Topic.
In the Create Topic panel, enter a topic name and description, set the Message Type parameter to Normal Message, and then click OK.
Create a consumer group
On the Instances page, click the name of the instance that you want to manage.
In the left-side navigation pane, click Groups. On the Groups page, click Create Group.
In the Create Group panel, configure the Group ID parameter and click OK. You can use the default values for other parameters in the panel.