Hello All,

ref stackoverflow :
https://stackoverflow.com/questions/74396652/confluent-schema-registry-why-is-auto-register-schemas-not-applicable-at-schem

---

I've installed the Schema Registry and want to set the auto.register.schema
set to false - so only avro messages conforming to the registered schema
can be published to Kafka Topic.

>From what I understand, the property - auto.register.schemas is a Kafka
Producer property, and not a schema registry property.

Here is the code I use to set the property auto.register.schemas
```

Console Producer:

kafka-avro-console-producer --bootstrap-server localhost:9092
--property schema.registry.url=http://localhost:8081 --topic
srtest-optionalfield --property
value.schema='{"type":"record","name":"myrecord","fields":[{"name":"f2","type":"string"}]}'
--property 
value.subject.name.strategy=io.confluent.kafka.serializers.subject.RecordNameStrategy
--property auto.register.schemas=false

Java Kafka Avro Producer :

Properties props = new Properties();
props.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, "http://localhost:9092";);
props.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, StringSerializer.class);
props.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG,
KafkaAvroSerializer.class);
props.put(ProducerConfig.CLIENT_ID_CONFIG, "Kafka Avro  Producer");
props.put("schema.registry.url", "http://localhost:8081";);
props.put(AbstractKafkaAvroSerDeConfig.AUTO_REGISTER_SCHEMAS, false);

```

Does this mean that - if a Kafka producer passes the property
auto.register.schemas=true, it will be able to add the schema to the Schema
Registry ?

This does not provide safeguard, since I want to ensure that producer is
allowed to produce only messages that conform to schemas in Schema Registry

How do I do this ? Is there a way for me to set the property -
auto.register.schemas - at the Schema Registry level ?

tia!

Reply via email to