All Products
Search
Document Center

ApsaraMQ for RocketMQ:Create resources

Last Updated:Nov 02, 2023

Before you use a TCP client SDK to send and receive messages, you must create the required resources in the ApsaraMQ for RocketMQ console. When you use the SDK, you must configure the resource parameters based on the resource information.

Before you start

Activate AsparaMQ for RocketMQ and grant permissions to a RAM user

Background information

ApsaraMQ for 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 Manage groups.

Limits on network access

Before you use ApsaraMQ for RocketMQ, take note of the following limits on network access:

  • A topic can be accessed by a producer or a consumer only if the group to which the producer or consumer belongs is created in the same region and instance as the topic. 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.

  • Public endpoints and private endpoints for TCP and HTTP are provided in all regions. In production environments, we recommend that you access ApsaraMQ forRocketMQ by using a Virtual Private Cloud (VPC). If you want to access ApsaraMQ forRocketMQ across regions, in on-premises data centers, or over the Internet, and Cloud Enterprise Network (CEN) is not available, you can use public endpoints. You are charged for outbound traffic when you use public endpoints. For more information, see Internet traffic fee.

  • ApsaraMQ for RocketMQ provides TCP endpoints and HTTP endpoints. Each type of endpoint can be used only for clients over the same protocol. For example, if you use a TCP client SDK, you can specify only a TCP endpoint in the code.

Create an instance

An instance is a virtual machine that provides the ApsaraMQ for RocketMQ service. An instance stores topics and group IDs.

  1. Log on to the ApsaraMQ for RocketMQ console.

  2. In the left-side navigation pane, click Instances.

  3. In the top navigation bar, select a region. Example: China (Hangzhou).

  4. On the Instances page, click Create Instance.

  5. In the Create Message Queue for Apache RocketMQ Instance panel, configure the Instance Type, Name, and Description parameters and click OK.

    Create an instance

    For more information about the billing of Standard Edition and Enterprise Platinum Edition instances, see Billing overview.

    After the instance is created, the instance is displayed on the Instances page.

Create a topic

A topic is a first-level identifier that is used to classify messages in ApsaraMQ for RocketMQ. For example, you can create a topic named Topic_Trade for transactional messages. Message producers send messages to Topic_Trade. Message consumers subscribe to Topic_Trade to consume the messages. Topics must meet the following requirements:

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

  1. On the details page of the instance, click Topics in the left-side navigation pane.

  2. On the Topics page, click Create Topic.

  3. In the Create Topic panel, configure the Name and Description parameters, set the Message Type parameter to Normal Message, and then click OK.

    Note

    In the following example, normal messages are used. The topic that you create by performing the steps that are described in this section cannot be used to send or receive messages of other types. Each topic can be used to send and receive only messages of a specific type. For information about message types, see Message types.

    The topic that you created appears in the topic list and the value of the Status parameter for the topic is Enabled.

    Note

    If the value of the Status parameter for the topic is Creating, refresh the page until the status of the topic changes to Enabled. You can use the topic only after the status of the topic changes to Running.

Create a group ID

You can create a group ID to identify producers or consumers of the same type. Group IDs must meet the following requirements:

  • You can create up to 1,000 groups in an instance. We recommend that you reuse groups or delete groups that are not used at the earliest opportunity. If you want to increase the limit on groups, contact ApsaraMQ for RocketMQ technical support.
  • 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 ApsaraMQ for 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 in the same group consume messages over different protocols, message consumption may fail, and message duplication or 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 displayed in the console, the data displayed in the console can be inaccurate. This does not affect the messaging of the group. You can contact ApsaraMQ for RocketMQ technical support to change the protocol that is displayed in the console to the protocol that is being used for the group.
  • A group ID must be specified for each consumer. You do not need to specify a group ID for each producer.
  1. On the details page of the instance, click Groups in the left-side navigation pane.

  2. On the Groups page, choose TCP > Create Group.

  3. In the Create Group for TCP Protocol panel, configure the Group ID and Description parameters and click OK.

    The ID of the group that you created appears in the group ID list.

Obtain an endpoint

After you create resources in the ApsaraMQ forRocketMQ console, you must obtain the endpoint that can be used to access an instance in the ApsaraMQ for RocketMQ console. Before you send and receive messages, you must specify the endpoint. This way, the producers and consumers can use the endpoint to access an instance in a specific region.

  1. On the details page of the instance, click Instance Details in the left-side navigation pane.

  2. On the Instance Details page, click the Endpoints tab.

  3. In the TCP Endpoint section, move the pointer over the endpoint and click the endpoint to copy the endpoint.

    The TCP endpoint for a Message Queue for Apache RocketMQ instance

    Before you use endpoints, take note of the following points:

    • The HTTP endpoint and TCP endpoint of the same instance cannot be interchangeably used. For example, if you want to use a TCP client SDK to send and receive messages, you must use the TCP endpoint of your ApsaraMQ forRocketMQ instance to connect to the ApsaraMQ for RocketMQ broker.

    • Public endpoints and private endpoints for TCP and HTTP are provided in all regions. In production environments, we recommend that you access ApsaraMQ forRocketMQ by using a Virtual Private Cloud (VPC). If you want to access ApsaraMQ forRocketMQ across regions, in on-premises data centers, or over the Internet, and Cloud Enterprise Network (CEN) is not available, you can use public endpoints. You are charged for outbound traffic when you use public endpoints. For more information, see Internet traffic fee.

After you complete the preceding operations, you can run the sample code and use ApsaraMQ for RocketMQ to send and subscribe to messages.

What to do next

Call TCP client SDKs to send and subscribe to normal messages