C++ SDK usage instructions

Updated at:

Describes how to set up the DataHub C++ SDK, including prerequisites, download, and client initialization.

Prerequisites

Before you begin, ensure that you have:

Download the C++ SDK

Download the SDK package for your target version:

Initialize the environment

To authenticate with DataHub, you need:

  • An AccessKey ID and AccessKey Secret. For more information, see Create an AccessKey pair.

  • The endpoint of your DataHub service. Find the endpoint on the DataHub console project page.

Create a DatahubClient using DataHub domain names:

    /* Credentials */
    Account account;
    account.id = "your_accesskey_id";      // Your AccessKey ID
    account.key = "your_accesskey_secret"; // Your AccessKey Secret

    /* DataHub project and topic */
    std::string projectName = "test_project"; // Name of the DataHub project
    std::string topicName = "test_cpp";       // Name of the topic within the project
    std::string comment = "test";

    /* Service endpoint */
    std::string endpoint = "";  // DataHub endpoint, e.g., https://dh-cn-hangzhou.aliyuncs.com
    Configuration conf(account, endpoint);

    /* Initialize the client */
    DatahubClient client(conf);

Next steps

After initializing the client, you can publish and subscribe to topics using the DataHub C++ SDK.