After you configure a change tracking task, you can use the SDK demo code that is provided by DTS to track and consume data. This topic describes how to use the SDK demo code to consume tracked data.

Prerequisites

A change tracking task of the previous version is configured. For more information, see Track data changes from an ApsaraDB RDS for MySQL instance (previous).

Before you begin

Create an AccessKey pair, which consists of an AccessKey ID and AccessKey secret. For more information, see Create an AccessKey pair.

Notice If you track and consume data as a RAM user, the AliyunDTSFullAccess permission must be granted to the RAM user. For more information, see Authorize a RAM user to use DTS.

Procedure

IntelliJ IDEA (Community Edition 2018.1.4 Windows) is used in this example.

  1. Download the SDK demo code package, and then decompress the package.
  2. Optional:Go to the directory where the package is decompressed, open the pom.xml file by using a text editor, and then change the SDK version to the latest.
    Set the SDK version
    Notice You can obtain the latest version of the change tracking SDK from the Maven website. For more information, visit the Maven page of the change tracking SDK.
  3. Open IntelliJ IDEA. In the window that appears, click Open.
    Open a project
  4. In the dialog box that appears, go to the directory where the package is decompressed, and expand the folders to find the pom.xml file.
    Find the pom.xml file
  5. In the dialog box that appears, select Open as Project.
  6. On the IntelliJ IDEA page, expand the folders to find the demo file of the Java client, and double-click the file. The file name is Main.java.
    Open the demo file of the Java client
  7. Set the parameters for the demo file of the Java client.
    Set parameters
    Parameter Description
    accessKey Enter the AccessKey ID and AccessKey secret of your Alibaba Cloud account. For more information, see Before you begin.
    accessSecret
    subscribeInstanceID Enter the ID of the change tracking instance. To obtain the ID of the change tracking instance, you must log on to the DTS console, and then click Change Tracking in the left-side navigation pane.
  8. On the top of the IntelliJ IDEA page, choose Run > Run to run the client.
    Note On the first run, the software loads and installs the relevant dependency package.

Result

The following figure shows that the Java client can track data changes from the source database.

Running result of the SDK demo code