Search code examples
apache-kafkakafka-producer-apiconfluent-schema-registry

Use RecordNameStrategy using kafka-avro-console-producer and confluent schema registry


Using the kafka-avro-console-producer cli When trying the following command

kafka-avro-console-producer \
 --broker-list <broker-list> \
 --topic <topic>  \
 --property schema.registry.url=http://localhost:8081 \
 --property value.schema.id=419
 --property auto.register=false

I have this error

org.apache.kafka.common.errors.SerializationException: Error retrieving Avro schema {...} 
Caused by: io.confluent.kafka.schemaregistry.client.rest.exceptions.RestClientException: Subject 'my-topic-name-value' not found.; error code: 40401

Since I’m not using TopicNameStrategy for my subjects but RecordNameStrategy. I would like to specify it, how can I find the property allowing to set the subject name to use by the cli please ?

Note: I, since I found this https://github.com/confluentinc/schema-registry/blob/a0a04628687a72ac6d01869d881a60fbde4177e7/avro-serializer/src/main/java/io/confluent/kafka/serializers/AbstractKafkaAvroSerDeConfig.java#L97 I already tried the following without much success

--property value.subject.name.strategy.default=io.confluent.kafka.serializers.subject.RecordNameStrategy

Solution

  • This worked

    --property value.subject.name.strategy=io.confluent.kafka.serializers.subject.RecordNameStrategy
    

    https://github.com/confluentinc/schema-registry/blob/master/schema-serializer/src/main/java/io/confluent/kafka/serializers/AbstractKafkaSchemaSerDeConfig.java#L136