Joe
Joe

Reputation: 13091

Kafka - Can you create schema before topic exist and what is the relation?

Is there any order that must be followed - e.g. person should create a topic first and then schema in schema registry or vice versa?

Can two topics use the same schema from Schema Registry?

Does every topic needs to have Key and Value? (and therefore needs to exist 2 schemas for each topic?)

What is the relation and possible combinations?

Thanks.

Upvotes: 2

Views: 1241

Answers (1)

OneCricketeer
OneCricketeer

Reputation: 191671

is there any order that must be followed

Nope. If you have auto topic creation enabled, you could even start producing Avro immediately to a non existing topic. The Confluent serializers automatically register the schema, and the broker will create a topic with default partitions and replicas

Can two topics use the same schema

Yes, the Avro Schema ID of two distinct topics can be the same. For example, Avro key of a string shared over more than one topic will cause two subjects to be entered into the registry, however, only one schema ID will back them

Does every topic needs to have Key and Value?

Yes. Thats part of the Kafka Record protocol. The key can be nullable, however. If you're not using Avro serializer for either key or value, no entry will be made. You're not required to use Avro for both options if one or the other is

Upvotes: 3

Related Questions