Step 2: Create resources

更新时间:
复制 MD 格式

Before you use the SDK to send and receive messages, you must create the required resources for Message Queue for Apache RocketMQ in advance. This involves creating an instance of Message Queue for Apache RocketMQ, obtaining the instance endpoint, creating a topic, and creating a consumer group. When you call the SDK, you must specify this resource information in the SDK code.

Prerequisites

Background information

You can create Message Queue for Apache RocketMQ resources in the console or by calling API operations. This topic describes how to create resources in the Message Queue for Apache RocketMQ console.

To create resources by using OpenAPI, see the following topics:

Limits

  • Region restrictions

    Ensure the Message Queue for Apache RocketMQ instance you create is in the same region as the VPC and vSwitch from the prerequisites.

  • Naming conventions

    For the naming conventions for Message Queue for Apache RocketMQ 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

  1. Log on to the ApsaraMQ for RocketMQ console. In the left-side navigation pane, click Instances.

  2. In the top navigation bar, select a region, for example, China (Hangzhou).

  3. 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.

    Message Queue for Apache 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.

      Note

      Serverless 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). More regions will be supported. For details about availability, see Supported regions.

    For more information about the differences in billable items and applicable scenarios, see Billing overview.

  4. 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 more information about the parameters and their valid values, 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.

    Important

    After a Message Queue for Apache RocketMQ instance is created, the selected VPC cannot be changed. To change the associated VPC, you must first release the purchased Message Queue for Apache RocketMQ 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.

    Important

    After a Message Queue for Apache RocketMQ instance is created, the selected vSwitch cannot be changed. To modify the associated vSwitch, you need to first release the purchased Message Queue for Apache RocketMQ instance and then purchase a new one.

    Internet Access

    Off

    Note
    • This topic uses the scenario of accessing the Message Queue for Apache RocketMQ server from a VPC as an example. Internet access is disabled by default. If you need to access Message Queue for Apache RocketMQ over the internet, you need to 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.

    Important

    Once a Message Queue for Apache RocketMQ instance is created, the selected VPC cannot be changed. To change the associated VPC, you must first release the purchased Message Queue for Apache RocketMQ instance and then purchase a new one.

    vSwitch ID

    vsw-bp1vqb0p9nz3irz******

    The ID of the vSwitch that you created in the prerequisites.

    Important

    After a Message Queue for Apache RocketMQ instance is created, the selected vSwitch cannot be changed. To change the associated vSwitch, you must first release the purchased Message Queue for Apache RocketMQ instance and then purchase a new one.

    Public access type

    Off

    Note

    This topic provides an example of accessing a Message Queue for Apache RocketMQ server by using a VPC. Internet access is disabled by default. If you need to access Message Queue for Apache RocketMQ over the internet, you need to set the Internet access type to Enabled.

    Resource Group

    Select the default resource group.

    Disk Encryption

    Off

    Note

    Disk encryption is supported only for Platinum Edition instances.

    Disk Encryption Key

    key-hzz66c8207****

    Note

    The 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

  1. On the Instances page, click the name of the target instance.

  2. On the Instance Details page, view the endpoint information in the TCP Endpoint section.

    • VPC endpoint: Use this endpoint to access Message Queue for Apache RocketMQ from a VPC. This is the default endpoint provided by Message Queue for Apache RocketMQ.

    • Public endpoint: Use this endpoint to access Message Queue for Apache RocketMQ over the internet. This endpoint is displayed only if public access is enabled.

Obtain the instance username and password

Note

This topic demonstrates how to obtain an instance's system username and password by using the default access control method: intelligent authentication.

If you want to use access control list (ACL) authentication, you must create an ACL user and permissions, and then obtain the ACL username and password. For more information, see User authentication.

When a client connects to the Message Queue for Apache RocketMQ server, you must configure a username and password based on the access method.

  • To access the Message Queue for Apache RocketMQ server over the internet: You must configure the instance username and password.

  • To access the Message Queue for Apache RocketMQ 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.

  1. On the Instances page, click the name of the target instance.

  2. In the navigation pane on the left, click Access Control.

  3. Click the Intelligent Authentication tab to view the Username and Password of the instance.

Create a topic

  1. On the Instances page, click the name of the target instance.

  2. In the navigation pane on the left, click Topics. Then, on the Topics page, click Create Topic.

  3. 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

  1. On the Instances page, click the name of the target instance.

  2. In the navigation pane on the left, click Groups. Then, on the Groups page, click Create Group.

  3. In the Create Group panel, enter a Group ID, leave the other parameters at their default settings, and then click OK.

Next steps

Step 3: Use an SDK to send and receive messages