Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Passing Schema Registry URL twice to instantiate KafkaAvroSerializer #877

Open
jeqo opened this issue Aug 28, 2018 · 1 comment

Comments

Projects
None yet
3 participants
@jeqo
Copy link

commented Aug 28, 2018

In some scenarios, some wrapping libraries require to instantiate KafkaAvroSerializer explicitly (e.g. Kafka Streams, Akka Streams):

final Map<String, Object> schemaRegistryConfigs = new HashMap<>();
    schemaRegistryConfigs.put(
        AbstractKafkaAvroSerDeConfig.SCHEMA_REGISTRY_URL_CONFIG,
        config.schemaRegistryUrl());
final KafkaAvroSerializer kafkaAvroSerializer = new KafkaAvroSerializer(schemaRegistryClient);
    kafkaAvroSerializer.configure(schemaRegistryConfigs, false);
...

So, schemaRegistryClient can be mocked on unit-tests, etc.

The issue is that you have to set Schema Registry URL to instantiate CachedSchemaRegistryClient https://github.com/confluentinc/schema-registry/blob/master/client/src/main/java/io/confluent/kafka/schemaregistry/client/CachedSchemaRegistryClient.java#L52
But also, to schemaRegistryConfigs. If not, it will fail when configuring kafkaAvroSerializer, here: https://github.com/confluentinc/schema-registry/blob/master/avro-serializer/src/main/java/io/confluent/kafka/serializers/AbstractKafkaAvroSerDe.java#L52 if URL is not set on configs, validation fails:

Caused by: io.confluent.common.config.ConfigException: Missing required configuration "schema.registry.url" which has no default value.

Is there any way to make this a bit more friendly and pass URL only once?

@rayokota rayokota added the enhancement label Nov 9, 2018

@tomaszszlek

This comment has been minimized.

Copy link

commented Dec 20, 2018

I had exactly the same issue but in my case application started, was able to query schema registry but it didn't auto create a schema for value serialization when using Kafka producer so the issue was very hard to discover.
Please note that the validation mentioned by @jeqo didn't work or at least allow to run application in my case (no fail fast).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.