Skip to content

Commit

Permalink
[allow_configuring_avro_consumer] Debugging / fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
emagdel committed Nov 17, 2021
1 parent 36c89df commit c6588a7
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/main/java/kafdrop/util/AvroMessageDeserializer.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,21 @@ private static KafkaAvroDeserializer getDeserializer(String schemaRegistryUrl, S

private static void setConfigFromEnvIfAvailable(String topicName, String configPath, Map<String,Object> config){

System.out.println("-----------STARTING topic name: " + topicName);
String configPrefix = "SCHEMA_REGISTRY";
String topicScopedEnvPath = Arrays.stream(new String[]{configPrefix, configPath.replace(".", "_"), topicName.replace("-", "_") } )
String topicScopedEnvPath = Arrays.stream(new String[]{configPrefix, configPath.replaceAll("\\.", "_"), topicName.replaceAll("-", "_") } )
.map(String::toUpperCase).collect(Collectors.joining("_"));

String noTopicScopedEnvPath = Arrays.stream(new String[]{ "SCHEMA_REGISTRY", configPath.replace(".", "_") })
String noTopicScopedEnvPath = Arrays.stream(new String[]{ configPrefix, configPath.replaceAll("\\.", "_") })
.map(String::toUpperCase).collect(Collectors.joining("_"));

for(String envPath : new String[]{topicScopedEnvPath, noTopicScopedEnvPath}) {

String namingStrategyValue = System.getenv(envPath);
System.out.println("-----------STARTING topic name: " + envPath + " " + namingStrategyValue);
if (namingStrategyValue != null) {
config.put(envPath, namingStrategyValue);
System.out.println("-----------STARTING topic name: " + envPath + " " + namingStrategyValue);
config.put(configPath, namingStrategyValue);
}
}
}
Expand Down

0 comments on commit c6588a7

Please sign in to comment.