无法将主题数据反序列化到Avro接收器连接器

时间:2020-03-30 14:56:34

标签: apache-kafka-connect confluent-platform

我正在使用汇合并将rdbms连接到kafka,并且它可以工作。 一些使用KSQL的ETL可以工作。但是,当我想将流/表沉回到rdbms时,现在出现了问题。

检查我的主题/信息流是否存在avro:

./bin/kafka-avro-console-consumer --bootstrap-server localhost:9092 --property schema.registry.url=http://localhost:8081 --from-beginning --max-messages 1 --topic STR_VAHG_REKEY_02 | jq '.'

结果:

{ “ REKEY02”:{ “长”:3941641584970777000 } }

似乎工作正常,但是当我下沉时:

org.apache.kafka.connect.errors.ConnectException: Tolerance exceeded in error handler\n\
tat org.apache.kafka.connect.runtime.errors.RetryWithToleranceOperator.execAndHandleError(RetryWithToleranceOperator.java:178)\n\
tat org.apache.kafka.connect.runtime.errors.RetryWithToleranceOperator.execute(RetryWithToleranceOperator.java:104)\n\
tat org.apache.kafka.connect.runtime.WorkerSinkTask.convertAndTransformRecord(WorkerSinkTask.java:484)\n\
tat org.apache.kafka.connect.runtime.WorkerSinkTask.convertMessages(WorkerSinkTask.java:464)\n\
tat org.apache.kafka.connect.runtime.WorkerSinkTask.poll(WorkerSinkTask.java:320)\n\
tat org.apache.kafka.connect.runtime.WorkerSinkTask.iteration(WorkerSinkTask.java:224)\n\
tat org.apache.kafka.connect.runtime.WorkerSinkTask.execute(WorkerSinkTask.java:192)\n\
tat org.apache.kafka.connect.runtime.WorkerTask.doRun(WorkerTask.java:177)\n\
tat org.apache.kafka.connect.runtime.WorkerTask.run(WorkerTask.java:227)\n\
tat java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)\n\
tat java.util.concurrent.FutureTask.run(FutureTask.java:266)\n\
tat java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)\n\
tat java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)\n\
tat java.lang.Thread.run(Thread.java:748)\n
Caused by: org.apache.kafka.connect.errors.DataException: Failed to deserialize data for topic STR_VAHG_REKEY_02 to Avro: \n\
tat io.confluent.connect.avro.AvroConverter.toConnectData(AvroConverter.java:110)\n\
tat org.apache.kafka.connect.runtime.WorkerSinkTask.lambda$convertAndTransformRecord$0(WorkerSinkTask.java:484)\n\
tat org.apache.kafka.connect.runtime.errors.RetryWithToleranceOperator.execAndRetry(RetryWithToleranceOperator.java:128)\n\
tat org.apache.kafka.connect.runtime.errors.RetryWithToleranceOperator.execAndHandleError(RetryWithToleranceOperator.java:162)\n\t... 
13 more\n
Caused by: org.apache.kafka.common.errors.SerializationException: Error deserializing Avro message for id -1\n
Caused by: org.apache.kafka.common.errors.SerializationException: Unknown magic byte!\n"

这是我的接收器文件:

connector.class=io.confluent.connect.jdbc.JdbcSinkConnector
tasks.max=1
topics=STR_VAHG_REKEY_02
connection.url=jdbc:mysql://
connection.user=
connection.password=
auto.create=true
timestamp.column.name=create_at
validate.non.null=false
key.converter=io.confluent.connect.avro.AvroConverter
key.converter.schema.registry.url=http://localhost:8081
value.converter=io.confluent.connect.avro.AvroConverter
value.converter.schema.registry.url=http://localhost:8081

我已经迷路了,任何建议都很好

1 个答案:

答案 0 :(得分:1)

您的avro-console-consumer输出正确显示是Avro-但是ksqlDB将消息 keys 作为字符串而不是Avro写入。

替换这两行

key.converter=io.confluent.connect.avro.AvroConverter
key.converter.schema.registry.url=http://localhost:8081

使用

key.converter=org.apache.kafka.connect.storage.StringConverter