tencent cloud

Data Transfer Service

JSON Demo Description

Unduh
Mode fokus
Ukuran font
Terakhir diperbarui: 2026-11-05 10:31:38
Diterjemahkan oleh AI
In the Demo, we use JSON for serialization, and each language-specific Demo includes a Record definition file.
The definition file path in the Java Demo is: consumerDemo-json-java\\src\\main\\java\\json\\FlatRecord.java.

Field Types in a Record

Field Name in Record
Description
id
Globally incrementing ID.
version
Protocol version. The current version is 1.
messageType
Message type. Enum values: "INSERT", "UPDATE", "DELETE", "DDL", "BEGIN", "COMMIT", "HEARTBEAT", "CHECKPOINT".
fileName
Name of the binlog file where the current record resides.
position
End offset of the current record in the binlog, in the format of End_log_pos@binlog file number. For example, if the current record is in the file mysql-bin.000004 and its end offset is 2196, the value is "2196@4".
safePosition
Start offset of the current transaction in the binlog, in the same format as above.
timestamp
Time when written to the binlog, in unix timestamp format with second-level precision.
The timestamp in the event header corresponding to the transaction recorded in the binlog. Long-running transactions on the source may cause a time difference between timestamp and readerTimestamp, which is normal.
gtid
Current gtid, for example, c7c98333-6006-11ed-bfc9-b8cef6e1a231:9.
transactionId
Transaction ID. A transaction ID is generated only for commit events.
serverId
Source database serverId. To view the source database server_id, refer to SHOW VARIABLES LIKE 'server_id'.
threadId
Session ID that commits the current transaction. For reference, see SHOW processlist;.
sourceType
Database type of the source database. The current version supports only MySQL.
sourceVersion
Source database version. To view the source database version, refer to select version();.
schemaName
Database name.
tableName
Table name.
objectName
Format: database_name.table_name.
columns
Definitions of columns in the table.
oldColumns
Data of the row before DML execution. For insert messages, this array is null.
newColumns
Data of the row after DML execution. For delete messages, this array is null.
sql
SQL statement of the DDL.
executionTime
DDL execution duration, in seconds.
heartbeatTimestamp
Timestamp of the heartbeat message, in seconds. Only heartbeat messages have this field.
syncedGtid
GTID set parsed by DTS, in the format of c7c98333-6006-11ed-bfc9-b8cef6e1a231:1-13.
fakeGtid
Whether it is a constructed fake GTID. If gtid_mode is not enabled, DTS constructs a GTID.
pkNames
If the table in the source database has a primary key, the DML message carries this parameter; otherwise, it does not.
readerTimestamp
Time when DTS processes this data, in unix timestamp format with millisecond-level precision.
tags
status_vars in QueryEvent. For details, refer to QueryEvent.
total
If a message is fragmented, records the total number of fragments. This field is meaningless in the current version (version = 1) and is reserved for future extension.
index
If a message is fragmented, records the index of the current fragment. This field is meaningless in the current version (version = 1) and is reserved for future extension.

MySQL Column Attributes in a Record

name: Column name.
dataTypeNumber: The data type recorded in the binlog. For valid values, see MySQL.
isKey: Whether the column is a primary key.
originalType: The type defined in the DDL.

MySQL Data Type Conversion Logic

In the JSON protocol, all MySQL types are converted to strings.
String types such as varchar are all converted to UTF8 encoding.
Numeric types are all converted to strings identical to their values, such as "3.0".
For time types, the format is: YYYY-MM-DD HH:mm:ss.SSS.
For timestamp types, the output is in milliseconds.
For binary types such as binary and blob, the output is a string identical to the hexadecimal value, such as "0xfff".

Bantuan dan Dukungan

Apakah halaman ini membantu?

masukan