I try to understand how Kafka Streams API works with Schema Registry.
Kafka Streams integrates with Confluent Schema Registry through the use of a Schema-Registry-aware Serde (serializer/deserializer) in your Kafka Streams application. Today, Schema Registry supports only Avro as the data format (additional formats like Protobuf and JSON are planned), hence there is an Avro Serde that integrates with Schema Registry. See Confluent's Kafka Streams documentation on 'Avro Serde'.
I know that you must specify Schema Registry URL when you setup your application
And that is why, see above, you must specify the SR URL when configuring your Kafka Streams application, because this setting will be passed from Kafka Streams to the Avro Serde.
I cannot understand how my application retrieves correct schema from registry without specifying a subject name or ID.
The subject name in Schema Registry a combination of topic name and a suffix, which is either -key
or -value
depending on whether the Serde is used to serialize/deserialize a Kafka message key or a Kafka message value, respectively (see Schema Registry documentation on 'Subjects'). In other words, there is a naming convention that maps a Kafka topic (that is read from or written to by your Kafka Streams application with the Avro serde) and subjects in Schema Registry.
Also, a schema may have a schema ID, which is used to disambiguate schema resolution in situations when there are multiple schemas registered under the same subject (and thus topic). See Schema Registry documentation on 'Schema IDs'.