Reputation: 449
I have Kafka Producer application.
The producer will receive metadata (the schema information from external source) and data. Let's say currently the topic_table_A and topic_table_B topics and their avro schemas exists in Kafka.
Then a new table_C matadata and data are received by the producer application so the producer has to create the new topic and its avro key/value schemas.
Is it possible to create a schema before a topic using the Schema Registry API Reference?
The api doesn't mention POST in subjects anyway, I tried something like: POST /subjects + Body Avro Json
The response was:
{
"error_code": 405,
"message": "HTTP 405 Method Not Allowed"
}
The dilemma is that the Producer Application can auto-create the topic sending the message to Kafka with a new topic name. But how can we create the avro schema in the schema registry before to create a new topic so the first message can be serialized?
Upvotes: 0
Views: 1770
Reputation: 191743
The api doesn't mention POST in subjects
Yes it does.
You need to post a schema "as a version of a subject". Not "post a subject"
POST /subjects/(string: subject)/versions
Only GET is allowed to "list subjects"
Upvotes: 1
Reputation: 1561
Even if you have auto-creation enabled you don't need to register schema in advance. The schema will be registered with the first message and the topic will be created correctly.
You can also create a new schema with REST API. The link is here. Pay attention to the headers, they may be different depending on your version of schema registry. If you receive 405 error, probably some of the request headers are missing.
Upvotes: 1