[英]Error handling for invalid JSON in kafka sink connector
I have a sink connector for mongodb, that takes json from a topic and puts it into the mongoDB collection.我有一个用于 mongodb 的接收器连接器,它从主题中获取 json 并将其放入 mongoDB 集合中。 But, when I send an invalid JSON from a producer to that topic (eg with an invalid special character ") =>
{"id":1,"name":"\\"}
, the connector stops. I tried using errors.tolerance = all, but the same thing is happening. What should happen is that the connector should skip and log that invalid JSON, and keep the connector running. My distributed-mode connector is as follows:但是,当我从生产者向该主题发送无效的 JSON(例如,使用无效的特殊字符 ") =>
{"id":1,"name":"\\"}
,连接器停止。我尝试使用错误。容忍=全部,但同样的事情正在发生。应该发生的是连接器应该跳过并记录无效的JSON,并保持连接器运行。我的分布式模式连接器如下:
{
"name": "sink-mongonew_test1",
"config": {
"connector.class": "com.mongodb.kafka.connect.MongoSinkConnector",
"topics": "error7",
"connection.uri": "mongodb://****:27017",
"database": "abcd",
"collection": "abc",
"type.name": "kafka-connect",
"key.ignore": "true",
"document.id.strategy": "com.mongodb.kafka.connect.sink.processor.id.strategy.PartialValueStrategy",
"value.projection.list": "id",
"value.projection.type": "whitelist",
"writemodel.strategy": "com.mongodb.kafka.connect.sink.writemodel.strategy.UpdateOneTimestampsStrategy",
"delete.on.null.values": "false",
"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",
"errors.tolerance": "all",
"errors.log.enable": "true",
"errors.log.include.messages": "true",
"errors.deadletterqueue.topic.name": "crm_data_deadletterqueue",
"errors.deadletterqueue.topic.replication.factor": "1",
"errors.deadletterqueue.context.headers.enable": "true"
}
}
Since Apache Kafka 2.0, Kafka Connect has included error handling options , including the functionality to route messages to a dead letter queue, a common technique in building data pipelines.
从Apache Kafka 2.0 开始,Kafka Connect 包含错误处理选项,包括将消息路由到死信队列的功能,这是构建数据管道的常用技术。
https://www.confluent.io/blog/kafka-connect-deep-dive-error-handling-dead-letter-queues/ https://www.confluent.io/blog/kafka-connect-deep-dive-error-handling-dead-letter-queues/
As commented, you're using connect-api-1.0.1.*.jar
, version 1.0.1, so that explains why those properties are not working正如评论的那样,您使用的是
connect-api-1.0.1.*.jar
,版本 1.0.1,这解释了为什么这些属性不起作用
Your alternatives outside of running a newer version of Kafka Connect include Nifi or Spark Structured Streaming除了运行较新版本的 Kafka Connect 之外,您的替代方案包括 Nifi 或 Spark Structured Streaming
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.