Before you use the SDK to send and receive messages, you must create the required ApsaraMQ for RocketMQ resources: an instance, a topic, and a consumer group. You also need the instance endpoint. You must specify these resources in your SDK code.
Prerequisites
Background information
You can create resources in the console or by calling API operations. The following procedure uses the console.
To create resources by using OpenAPI, see the following topics:
Limits
-
Region restrictions
Ensure the instance you create is in the same region as the VPC and vSwitch from the prerequisites.
-
Naming conventions
For the naming conventions for instances, topics, and consumer groups, see Quotas and limits.
-
Topic type restrictions
A topic's message type must match the type of messages that you send and receive. For example, if you create a topic for normal messages, you can use it only to send and receive normal messages, not ordered messages. For more information, see Topic usage recommendations.
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, for example, China (Hangzhou).
-
On the Instances page, click Create Instance. In the Create Message Queue for Apache RocketMQ Instance panel, set Instance Version to V5.0, select a Product Type, and then click OK.
ApsaraMQ for RocketMQ supports the following product types:
-
Subscription: A prepaid model where you are billed monthly for the instance's computing specification.
-
Pay-as-you-go: A postpaid model where you are billed hourly for the instance's computing specification.
-
Serverless: A pay-as-you-go model where you are billed based on the total number of message requests.
NoteServerless instances are available in the following regions: China (Hangzhou), China (Zhangjiakou), China (Beijing), China (Shenzhen), Singapore (Singapore), Germany (Frankfurt), US (Virginia), and US (Silicon Valley). Additional regions will be supported over time. For current availability, see Supported regions.
For details about billable items and applicable scenarios, see Billing overview.
-
-
On the buy page, select the instance specifications, click Buy Now, and complete the payment.
Refer to the following tables when creating an instance. For details about each parameter, see Select instance edition.
Serverless
Parameter
Example value
Primary Edition
Standard
Billing mode
The default is Pay-by-request.
Message storage specification
You do not need to select a storage capacity. You are billed for the actual storage space that you use.
VPC ID
vpc-bp1cg09dua6sgh0******
The ID of the VPC that you created in the prerequisites.
ImportantAfter an instance is created, the selected VPC cannot be changed. To change the associated VPC, you must first release the purchased instance and then purchase a new one.
vSwitch ID
vsw-bp1vqb0p9nz3irz******
The ID of the vSwitch that you created in the prerequisites.
You must select two vSwitch ID for a Serverless instance.
ImportantAfter an instance is created, the selected vSwitch cannot be changed. To modify the associated vSwitch, you need to first release the purchased instance and then purchase a new one.
Internet Access
Off
Note-
This procedure uses VPC access as an example, so Internet access is disabled by default. To access the service over the Internet, set Internet Access Type to Enabled.
Intranet access type
The default is Pay-By-Data-Transfer.
Serverless instances support only VPC access and do not support Internet access.
Resource Group
Select the default resource group.
Security Group
Select the security group that you created as part of the prerequisites.
Subscription or pay-as-you-go
Parameter
Example value
Primary Edition
Standard
Sub-category edition
Cluster High-availability Edition (Recommended for production environments)
Message sending and receiving computing specification
rmq.s2.2xlarge
VPC ID
vpc-bp1cg09dua6sgh0******
The ID of the VPC that you created in the prerequisites.
ImportantOnce an instance is created, the selected VPC cannot be changed. To change the associated VPC, you must first release the purchased instance and then purchase a new one.
vSwitch ID
vsw-bp1vqb0p9nz3irz******
The ID of the vSwitch that you created in the prerequisites.
ImportantAfter an instance is created, the selected vSwitch cannot be changed. To change the associated vSwitch, you must first release the purchased instance and then purchase a new one.
Public access type
Off
NoteThis procedure uses VPC access as an example, so Internet access is disabled by default. To access the service over the Internet, set the Internet access type to Enabled.
Resource Group
Select the default resource group.
Disk Encryption
Off
NoteDisk encryption is supported only for Platinum Edition instances.
Disk Encryption Key
key-hzz66c8207****
NoteThe ID of the key that is used for disk encryption in the same region. This parameter is required only when Disk Encryption is set to Enable.
-
Obtain the instance endpoint
-
On the Instances page, click the name of the target instance.
-
On the Instance Details page, view the endpoint information in the TCP Endpoint section.
-
VPC endpoint: Use this endpoint to access ApsaraMQ for RocketMQ from a VPC. This endpoint is provided by default.
-
Public endpoint: Use this endpoint to access the service over the Internet. This endpoint is displayed only if public access is enabled.
-
Obtain the instance username and password
The following steps show how to obtain the system username and password using the default access control method: intelligent authentication.
To use access control list (ACL) authentication instead, create an ACL user and configure permissions, and then use the ACL username and password. For more information, see User authentication.
When a client connects to the ApsaraMQ for RocketMQ server, configure a username and password based on the access method.
-
To access the server over the Internet: You must configure the instance username and password.
-
To access the server from a VPC: For Serverless instances, credentials are not required if authentication-free access is enabled. For other instance types, authentication is automatic and does not require credentials.
-
On the Instances page, click the name of the target instance.
-
In the navigation pane on the left, 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 target instance.
-
In the navigation pane on the left, click Topics. Then, on the Topics page, click Create Topic.
-
In the Create Topic panel, enter a topic name and description, set Message Type to Normal Message, and then click OK.
Create a consumer group
-
On the Instances page, click the name of the target instance.
-
In the navigation pane on the left, click Groups. Then, on the Groups page, click Create Group.
-
In the Create Group panel, enter a Group ID, leave the other parameters at their default settings, and then click OK.