Updated on 2023-11-30 GMT+08:00

Preparing the Environment

Helpful Links

To create a new project, use the downloaded SDK. To write code based on the sample project, use the SDK included in the project.

The following describes how to access DMS using a Java client in Linux.

Preparing Tools

Eclipse: Download Eclipse 3.6.0 or later from the Eclipse official website.

JDK: Download Java Development Kit 1.8.111 or later from the Oracle official website.

Apache Maven: Download Apache Maven 3.0.3 or later from the Maven official website.

Obtaining a Queue ID and Consumer Group ID

Before accessing DMS using the SDK, create a queue and consume group on the DMS console or by calling APIs.

Code of the Sample Project provides examples of the processes for producing and consuming messages.

The following describes the processes of creating a queue and a consumer group and obtaining the queue ID and consumer group ID on the DMS console. To learn how to perform these operations by calling APIs, see the DMS API Reference.

Procedure:

  1. Log in to the management console.
  2. Choose Service List > Application > Distributed Message Service to launch the DMS console.
  3. In the navigation pane, choose Queue Manager.
  4. On the Queue Manager page, click Create Queue.

    By default, a user can create a maximum of 30 queues. The number of queues that can be created is shown above the Delete button. If you want to create more queues, contact customer service to increase your quota.

  5. Specify queue parameters.

    Table 1 Parameter description

    Parameter

    Description

    Queue Name

    Name of the queue you want to create. The name must be unique.

    When creating a queue, a default queue name is generated, which you can change if required. A queue name consists of 1 to 64 characters. Only letters, digits, underscores (_), and hyphens (-) are allowed.

    The queue name cannot be modified after the queue is created.

    Queue Type

    • Standard queue: Partition-level FIFO mode and global FIFO mode are supported.
    • Kafka: Open-source Kafka clients can be used for creating and consuming messages. High throughput mode and high reliability mode are supported.

    Queue Mode

    When Queue Type is Standard, the queue mode can be:
    • Partition-level FIFO: Messages may be consumed out of sequence, but the concurrency is higher.
    • Global FIFO: Messages are consumed in the order they were sent.
    When Queue Type is Kafka, the queue mode can be:
    • High throughput: All message replicas are flushed to a disk asynchronously. Select this mode when high message delivery performance is required.
    • High reliability: All message replicas are flushed to disk synchronously. Select this mode when high message delivery reliability is required.

    Dead Letter Queue

    This parameter is available only for standard queues.

    This parameter indicates whether to enable dead letter messages. Dead letter messages are messages that cannot be correctly consumed.

    If a message fails to be consumed for a preset number of times, it will be sent to the dead letter queue and retained for 72 hours. You can then consume the message from the dead letter queue.

    Dead letter messages can be consumed only by the consumer group that generated these dead letter messages.

    Dead letter messages from global FIFO queues are sent to the dead letter queue in the FIFO order.

    By default, Dead Letter Queue is disabled.

    Maximum Retrievals

    This parameter is available only when dead letter messages are enabled.

    Maximum number of times a message can be consumed before it is sent to the dead letter queue.

    Value range: 1–100.

    Default value: 3

    Description (optional)

    The description consists of a maximum of 160 characters and cannot contain angle brackets (< and >).

    Figure 1 Creating a queue

  6. Click OK.
  7. Click the name of the queue. On the displayed queue details page, obtain the queue ID, as shown in Figure 2.

    Figure 2 Obtaining the queue ID

  8. Click Create Consumer Group.
  9. Enter a consumer group name.

    A default consumer group name is generated, which you can change if required. A consumer group name consists of 1 to 32 characters. Only letters, digits, underscores (_), and hyphens (-) are allowed. Consumer group names must be unique within the same queue.

  10. Click OK. Obtain the ID of the consumer group in the consumer group list, as shown in Figure 3.

    Figure 3 Obtaining the consumer group ID

Obtaining a Project ID

When calling APIs, you need to specify project_id in API requests. Obtain a project ID by performing the following procedure:

  1. Log in to the management console.
  2. Click the username and choose My Credential from the drop-down list.
  3. On the My Credentials page, view project IDs in the project list.

Obtaining an AK/SK

  1. Log in to the management console.
  2. Click the username and choose My Credential from the drop-down list.
  3. On the My Credentials page, click the Access Keys tab.
  4. Click Add Access Key.
  5. Enter the password for login.
  6. Enter the verification code sent to your mailbox or mobile phone.
  7. Click OK.

    Keep the access key ID (AK)/secret access key (SK) file secure.

  8. Download the credentials.csv file containing your AK and SK to a local computer.

Obtaining Region and Endpoint Information

Region

Endpoint

Description

CN-Hong Kong

dms-tcp.ap-southeast-1.myhuaweicloud.com

Use the endpoint to access DMS.

Creating an ECS

  1. Before using DMS TCP SDK to access DMS over public networks, you need to create an Elastic Cloud Server (ECS).

    Elastic IP addresses (EIPs) are used to log in to ECSs and upload files.

Collecting Environment Information

Table 2 Required environment information

Category

Information

Example

ECS

EIP

-

Username

-

Password

-

DMS

Queue name

-

Queue ID

-

Queue type

-

Queue mode

-

Consumer group name

-

Consumer group ID

-

AK/SK

AK

-

SK

-

Project

Region

-

Project name

-

Project ID

-

Region and endpoint

Region

-

Endpoint

-

DNS

DNS server IP Address

-