How to define custom subject name strategy in dotnet Confluent Kafka

76 views Asked by At

Currently Confluent Kafka dotnet supports three subject name strategy:

  1. Topic Name
  2. Record type
  3. TopicRecord type

I want to create a custom subject strategy where I can generate subject & schema with custom values. For example,

Subject : env.RecordTypeFullName

Please suggest

1

There are 1 answers

0
OneCricketeer On BEST ANSWER

As you've seen, there are none with "env" prefix. Since the values are an enum, there is no easy way to override this, and it will instead throw an exception.

https://github.com/confluentinc/confluent-kafka-dotnet/blob/master/src/Confluent.SchemaRegistry/SubjectNameStrategy.cs#L97

IMO, it is an anti-pattern to include an "env" prefix in your schemas since dev/test/stage should all be as close to "prod" as possible. Your registry server running in "non-prod" might have the env encoded in the URL, instead, but your schema name shouldn't. The topic name (i.e. subject name) could. Then you'd use the TopicName / TopicRecord Strategy