首页 > 解决方案 > how to enforce schema validation in kafka

问题描述

I'm using Kafka & Schema-registry. Defined a schema, using confluent's KafkaAvroSerializer on the producer side. Everything works fine.

On the other hand, if a producer publishes the event without adhering to the schema, it gets published without any problem.

Understood that Kafka gets just serialized binary, doesn't inspect the data and functionality works as designed.

Wondering if there is any better way to enforce stronger schema validation so that the topic is not polluted with bad data ?

标签: apache-kafkaconfluent-platformconfluent-schema-registry

解决方案


创建主题时使用以下“--config”标签。它们分别对值和键强制执行消息模式验证。这两条规则是相互独立的;您可以启用其中一个或两个。不合规的消息将导致客户端收到来自 kafka 代理的错误。

https://www.confluent.io/blog/data-governance-with-schema-validation/

confluent.value.schema.validation=true 
confluent.key.schema.validation=true

推荐阅读