卡夫卡 s3 连接"Value is not Struct type"错误



我使用以下参数加载 s3 连接器:

confluent load s3-sink
{
"name": "s3-sink",
"config": {
"connector.class": "io.confluent.connect.s3.S3SinkConnector",
"tasks.max": "1",
"topics": "s3_topic",
"s3.region": "us-east-1",
"s3.bucket.name": "some_bucket",
"s3.part.size": "5242880",
"flush.size": "1",
"storage.class": "io.confluent.connect.s3.storage.S3Storage",
"format.class": "io.confluent.connect.s3.format.json.JsonFormat",
"schema.generator.class": "io.confluent.connect.storage.hive.schema.DefaultSchemaGenerator",
"partitioner.class": "io.confluent.connect.storage.partitioner.FieldPartitioner",
"schema.compatibility": "NONE",
"partition.field.name": "f1",
"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",
"name": "s3-sink"
},
"tasks": [
{
"connector": "s3-sink",
"task": 0
}
],
"type": null
}

接下来,我用kafka控制台制作者JSON发送它:

{"f1":"partition","data":"some data"}

我在连接日志中收到以下错误:

[2018-05-16 16:32:05,150] ERROR Value is not Struct type. (io.confluent.connect.storage.partitioner.FieldPartitioner:67)
[2018-05-16 16:32:05,150] ERROR WorkerSinkTask{id=s3-sink-0} Task threw an uncaught and unrecoverable exception. Task is being killed and will not re
cover until manually restarted. (org.apache.kafka.connect.runtime.WorkerSinkTask:515)
io.confluent.connect.storage.errors.PartitionException: Error encoding partition.

我记得它前段时间奏效了。
现在我使用 Confluent 开源 v. 4.1

从Confluent 4.1版本开始,FieldPartitioner不支持JSON字段提取。

你可以改用kafka-avro-console-producer发送具有 Avro 架构的相同 JSON blob,然后它应该可以工作

这是您要使用的属性

--property value.schema='{"type":"record","name":"myrecord","fields":[{"name":"f1","type":"string"},{"name":"data","type":"string"}]}'

然后你可以发送

{"f1":"partition","data":"some data"}

你需要在 Connect 中使用这些属性

"value.converter": "io.confluent.connect.avro.AvroConverter",
"value.converter.schemas.enable": "true",

相关内容

  • 没有找到相关文章

最新更新