Change data capture (CDC) Beta

    If you haven’t installed YugabyteDB yet, do so first by following the Quick Start guide.

    A JRE (or JDK), for Java 8 or later, is installed. JDK and JRE installers for Linux, macOS, and Windows can be downloaded from , AdoptOpenJDK, or .

    Add a table, named users, to the default yugabyte database.

    1. CREATE TABLE products(
    2. id bigserial PRIMARY KEY,
    3. created_at timestamp,
    4. category text,
    5. ean text,
    6. price float,
    7. quantity int default(5000),
    8. rating float,
    9. title text,
    10. vendor text
    11. );

    Download the CDC Connector JAR file (yb-cdc-connector.jar).

    1. java -jar yb-cdc-connector.jar \
    2. --table_name yugabyte.products \
    3. --log_only

    The example above uses the following parameters:

    • —table_name — Specifies the namespace and table, where namespace is the database (YSQL) or keyspace (YCQL).
    • —master_addrs — Specifies the IP addresses for all of the YB-Master servers that are producing or consuming. Default value is 127.0.0.1:7100. If you are using a 3-node local cluster, then you need to specify a comma-delimited list of the addresses for all of your YB-Master servers.
    • —log_only: Flag to restrict logging only to the console (stdout).

    In another terminal shell, write some values to the table and observe the values on your stdout output stream.

    1. key {
    2. key: "id"
    3. value {
    4. int64_value: 14
    5. }
    6. }
    7. changes {
    8. key: "created_at"
    9. value {
    10. int64_value: 568046516870000
    11. }
    12. }
    13. changes {
    14. key: "category"
    15. value {
    16. string_value: "Widget"
    17. }
    18. }
    19. changes {
    20. key: "ean"
    21. value {
    22. string_value: "8833419218504"
    23. }
    24. }
    25. changes {
    26. double_value: 25.09876359271891
    27. }
    28. }
    29. changes {
    30. key: "quantity"
    31. value {
    32. int32_value: 5000
    33. }
    34. }
    35. changes {
    36. key: "rating"
    37. value {
    38. double_value: 4.0
    39. }
    40. }
    41. changes {
    42. key: "title"
    43. value {
    44. string_value: "Awesome Concrete Shoes"
    45. }
    46. }
    47. changes {
    48. key: "vendor"
    49. value {
    50. string_value: "McClure-Lockman"