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

Running the Sample Project

  1. Log in to the ECS.
  2. Install JDK or Java runtime environment (JRE). Add the following settings of environment variables JAVA_HOME and PATH to the ~/.bash_profile:

    export JAVA_HOME=/opt/java/jdk1.8.0_151
    export PATH=$JAVA_HOME/bin:$PATH

    Run the source .bash_profile command for the modification to take effect.

    Use Oracle JDK instead of ECS's default JDK (for example, OpenJDK), because ECS's default JDK may not be suitable for the sample project. To obtain Oracle JDK, download Java Development Kit 1.8.111 or a later version from the Oracle official website.

  3. Run the following command to download the code package of the sample project DmsTcpDemo:

    $ wget https://dms-demo.obs.cn-north-1.myhuaweicloud.com/DmsTcpDemoClient.zip

  4. Run the following command to decompress the DmsTcpDemoClient.zip package.

    $ unzip DmsTcpDemoClient.zip

  5. Run the following command to navigate to the DmsTcpDemoClient/dist directory which contains pre-complied binary files and executable scripts.

    $ cd DmsTcpDemoClient/dist

  6. Edit the config/dms.client.properties file and configure access_key, secret_key and project_id.

    $ vim config/dms.client.properties

    The red values are examples. Replace them with actual values.

    dms.server.ip=d 
    dms.server.port=60010
    dms.client.project.id=bd67aaead60940d688b872c31bdc663b
    dms.client.access.key=**************
    dms.client.secret.key=**************

  7. Execute the demo script by running the following command containing the queue ID and consumer group ID to test message production and consumption.

    $ bash dms_tcp_demo.sh 5964181e-b67e-4d35-9281-a58c352abda6 g-c861aa48-a082-48ff-bc9d-ff36fe7aed38

    After the command is run, 10 messages are sent to the queue, and then consumed. The consumption results will be returned.

  8. Log in to the to view the number of messages in a specified queue and verify the execution result of the demo script.