{"schema": {...},"payload": {...}}
Item | Field name | Description |
1 | schema | schema 字段描述了key的payload 字段的结构,即它描述了被修改的表的主键(primary key)结构,如果表没有主键,则描述其唯一约束(unique key)的结构。 |
2 | payload | payload 字段的结构和第一个schema 中描述的相同,包含了被修改的行的键值。 |
Item | Field name | Description |
1 | schema | schema 字段描述了 value 的payload 字段的结构,即描述了被修改行的字段结构。这个字段通常是一个嵌套结构的字段。 |
2 | payload | payload 字段的结构和 schema 中定义的相同,它包含被修改行的真实数据。 |
CREATE TABLE customers (id SERIAL,first_name VARCHAR(255) NOT NULL,last_name VARCHAR(255) NOT NULL,email VARCHAR(255) NOT NULL,PRIMARY KEY(id));
{"schema": {"type": "struct","name": "PostgreSQL_server.public.customers.Key","optional": false,"fields": [{"name": "id","index": "0","schema": {"type": "INT32","optional": "false"}}]},"payload": {"id": "1"},}
Item | Field name | Description |
1 | schema | Schema 描述了 payload 中的结构 |
2 | PostgreSQL_server.inventory.customers.Key | schema 的名称格式为 *connector-name*.*database-name*.*table-name*.Key。在这个例子中: PostgreSQL_server 是生成事件的 connector 的名字。 inventory 是对应数据库的名字。 customers 是表的名字。 |
3 | optional | 表示字段是否是可选项。 |
4 | fields | 列出了所有 payload 中包含的字段及其结构, 包括字段名、字段类型、以及是否可选. |
5 | payload | 包含被修改行的主键.。在例子中仅包含一个字段名为 id 的主键值: 1。 |
{"schema": {"type": "struct","fields": [{"type": "struct","fields": [{"type": "int32","optional": false,"field": "id"},{"type": "string","optional": false,"field": "first_name"},{"type": "string","optional": false,"field": "last_name"},{"type": "string","optional": false,"field": "email"}],"optional": true,"name": "PostgreSQL_server.inventory.customers.Value","field": "before"},{"type": "struct","fields": [{"type": "int32","optional": false,"field": "id"},{"type": "string","optional": false,"field": "first_name"},{"type": "string","optional": false,"field": "last_name"},{"type": "string","optional": false,"field": "email"}],"optional": true,"name": "PostgreSQL_server.inventory.customers.Value","field": "after"},{"type": "struct","fields": [{"type": "string","optional": false,"field": "version"},{"type": "string","optional": false,"field": "connector"},{"type": "string","optional": false,"field": "name"},{"type": "int64","optional": false,"field": "ts_ms"},{"type": "boolean","optional": true,"default": false,"field": "snapshot"},{"type": "string","optional": false,"field": "db"},{"type": "string","optional": false,"field": "schema"},{"type": "string","optional": false,"field": "table"},{"type": "int64","optional": true,"field": "txId"},{"type": "int64","optional": true,"field": "lsn"},{"type": "int64","optional": true,"field": "xmin"}],"optional": false,"name": "io.debezium.connector.postgresql.Source","field": "source"},{"type": "string","optional": false,"field": "op"},{"type": "int64","optional": true,"field": "ts_ms"}],"optional": false,"name": "PostgreSQL_server.inventory.customers.Envelope"},"payload": {"before": null,"after": {"id": 1,"first_name": "Anne","last_name": "Kretchmar","email": "annek@noanswer.org"},"source": {"version": "1.9.3.Final","connector": "postgresql","name": "PostgreSQL_server","ts_ms": 1559033904863,"snapshot": true,"db": "postgres","sequence": "[\\"24023119\\",\\"24023128\\"]""schema": "public","table": "customers","txId": 555,"lsn": 24023128,"xmin": null},"op": "c","ts_ms": 1559033904863}}
Item | Field name | Description |
1 | schema | Schema 描述了 payload 中的结构, 其中 schema 中的 fields 字段为一个数组,表示 payload 字段包含了多个字段,数组的每个元素是对 payload 中相应字段结构的描述信息。 |
2 | field | 每一个 fields 中的元素都包含一个 field 字段,该字段表示 payload 中对应字段的名称。在示例中包括 before、after、source等。 |
3 | type | 表示字段的类型,如整型(int)、字符串(string)等. |
4 | PostgreSQL_server.inventory.customers.Value | 表示该字段是 PostgreSQL_server 连接器生成的针对 inventory 数据库的 customers 表的 value 部分信息。 |
5 | io.debezium.connector.postgresql.Source | 该名称和特定的 connector 绑定,由该 connector 生成的事件该名称都相同。 |
6 | payload | 包含修改事件中具体被修改的数据,包括修改前(before 字段)和修改后(after 字段)的数据,以及一些 connector 的元数据信息(source 字段)。 |
7 | op | 表示导致事件生成的修改操作的类型,例子中的 c 表示 修改操作创建了一个新的行。c = createu = updated = deleter = read (仅 snapshots)t = truncatem = message |
8 | source | source 字段是一个描述事件元数据的字段。它包含的一些字段可以用来与其他事件做比较,如比较事件生成的顺序、事件是否属于同一个事务等。该字段包含以下元数据信息: Debezium versionConnector type and nameDatabase and table that contains the new rowStringified JSON array of additional offset information. The first value is always the last committed LSN, the second value is always the current LSN. Either value may be nullSchema nameIf the event was part of a snapshotID of the transaction in which the operation was performedOffset of the operation in the database logTimestamp for when the change was made in the database |
{"schema": { ... },"payload": {"before": {"id": 1},"after": {"id": 1,"first_name": "Anne Marie","last_name": "Kretchmar","email": "annek@noanswer.org"},"source": {"version": "1.9.3.Final","connector": "postgresql","name": "PostgreSQL_server","ts_ms": 1559033904863,"snapshot": false,"db": "postgres","schema": "public","table": "customers","txId": 556,"lsn": 24023128,"xmin": null},"op": "u","ts_ms": 1465584025523}}
{"schema": { ... },"payload": {"source": {"version": "1.9.3.Final","connector": "postgresql","name": "PostgreSQL_server","ts_ms": 1559033904863,"snapshot": false,"db": "postgres","schema": "public","table": "customers","txId": 556,"lsn": 46523128,"xmin": null},"op": "t","ts_ms": 1559033904961}}
{"schema": { ... },"payload": {"source": {"version": "1.9.3.Final","connector": "postgresql","name": "PostgreSQL_server","ts_ms": 1559033904863,"snapshot": false,"db": "postgres","schema": "","table": "","txId": 556,"lsn": 46523128,"xmin": null},"op": "m","ts_ms": 1559033904961,"message": {"prefix": "foo","content": "Ymfy"}}}
{"schema": { ... },"payload": {"source": {"version": "1.9.3.Final","connector": "postgresql","name": "PostgreSQL_server","ts_ms": 1559033904863,"snapshot": false,"db": "postgres","schema": "","table": "","lsn": 46523128,"xmin": null},"op": "m","ts_ms": 1559033904961"message": {"prefix": "foo","content": "Ymfy"}}
Field name | Description |
message | 该字段包含了消息的元数据: prefix(text) Content (byte array that is encoded based on the binary handling mode setting) |
{"schema": { ... },"payload": {"before": {"id": 1},"after": null,"source": {"version": "1.9.3.Final","connector": "postgresql","name": "PostgreSQL_server","ts_ms": 1559033904863,"snapshot": false,"db": "postgres","schema": "public","table": "customers","txId": 556,"lsn": 46523128,"xmin": null},"op": "d","ts_ms": 1465581902461}}
DELETE
event record has __debezium.newkey
as a message header. The value of this header is the new primary key for the updated row.CREATE
event record has __debezium.oldkey
as a message header. The value of this header is the previous (old) primary key that the updated row had.
本页内容是否解决了您的问题?