我正在尝试从有效负载中删除架构,这是配置
connector.properties
name=test-source-mysql-jdbc-autoincrement
connector.class=io.confluent.connect.jdbc.JdbcSourceConnector
value.converter=org.apache.kafka.connect.json.JsonConverter
tasks.max=1
connection.url=jdbc:mysql://127.0.0.1:3306/employee_db?user=root&password=root
table.whitelist=testemp
mode=incrementing
incrementing.column.name=employee_id
topic.prefix=test-mysql-jdbc-
及以下是我的 worker.properties
bootstrap.servers=localhost:9092
key.converter=org.apache.kafka.connect.json.JsonConverter
value.converter=org.apache.kafka.connect.json.JsonConverter
key.converter.schemas.enable=false
value.converter.schemas.enable=false
internal.key.converter=org.apache.kafka.connect.json.JsonConverter
internal.value.converter=org.apache.kafka.connect.json.JsonConverter
internal.key.converter.schemas.enable=false
internal.value.converter.schemas.enable=false
offset.storage.file.filename=/tmp/connect.offsets
offset.flush.interval.ms=10000
plugin.path=C:\Users\name\Desktop\kafka\libs
输出:
{"schema":{"type":"struct","fields":[{"type":"int32","optional":false,"field":"employee_id"},{"type":"string","optional":false,"field":"first_name"}],"optional":false,"name":"testemp"},"payload":{"employee_id":2,"first_name":"test"}}
例外的输出:
{"payload":{"employee_id":2,"first_name":"test"}}
我尝试根据here中的建议在worker中禁用value.converter.schemas.enable = false仍然无效
我想念什么吗?
答案 0 :(得分:1)
有两种解决方法:
value.converter
属性(您使用相同的value.converter
)value.converter.schemas.enable=false
。架构已添加到消息中,因为您已经覆盖了值转换器并且未禁用架构(默认情况下,JsonConverter
架构已启用)。从Kafka Connect的角度来看,您使用了全新的Converter(它将不使用全局配置中的属性)
如果您要禁用架构,您的消息将如下所示:
{
"employee_id": 2,
"first_name":"test"
}