From 211d637132dbd3b4ee73eb16929a5ee15c613a62 Mon Sep 17 00:00:00 2001 From: Hanzel Legarda Date: Wed, 23 Oct 2024 09:22:35 -0600 Subject: [PATCH] fix: code review comments, renaming client to consumer, modifying conf parameters to fill only with prefix params --- README.md | 22 +++++++++---------- .../dronefly/app/context/CommonBeans.java | 18 ++++++--------- 2 files changed, 18 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index bfc969d..61b68c6 100644 --- a/README.md +++ b/README.md @@ -91,14 +91,14 @@ The table below describes all the available configuration values for Drone Fly. | endpoint.port | Port on which Drone Fly Spring Boot app will start. | `string` | `8008` | no | ### Additional configuration parameters -The Kafka message reader supports client properties that are passed to the Kafka consumer builder. -These are environment variables with the PREFIX apiary.messaging.client. +The Kafka message reader supports properties that are passed to the Kafka consumer builder. +These are environment variables with the PREFIX apiary.messaging.consumer. - #### Example for sending client parameters when using a Kafka cloud provider -- apiary.messaging.client.security.protocol=SSL -- apiary.messaging.client.sasl.mechanism=AWS_MSK_IAM -- apiary.messaging.client.sasl_jaas.config=software.amazon.msk.auth.iam.IAMLoginModule required; -- apiary.messaging.client.sasl.client.callback.handler.class=software.amazon.msk.auth.iam.IAMClientCallbackHandler + #### Example for sending consumer parameters when using a Kafka cloud provider +- apiary.messaging.consumer.security.protocol=SSL +- apiary.messaging.consumer.sasl.mechanism=AWS_MSK_IAM +- apiary.messaging.consumer.sasl_jaas.config=software.amazon.msk.auth.iam.IAMLoginModule required; +- apiary.messaging.consumer.sasl.client.callback.handler.class=software.amazon.msk.auth.iam.IAMClientCallbackHandler In this case we are sending the properties to Kafka's consumer to be able to connect to AWS MSK which also requires the IAM library included as a dependency in the POM.xml file @@ -106,10 +106,10 @@ In this case we are sending the properties to Kafka's consumer to be able to con --apiary.bootstrap.servers=localhost:9092 \ --apiary.kafka.topic.name=apiary \ --apiary.listener.list="com.expediagroup.sampleListener1,com.expediagroup.sampleListener2" \ - --apiary.messaging.client.security.protocol=SSL \ - --apiary.messaging.client.sasl.mechanism=AWS_MSK_IAM \ - --apiary.messaging.client.sasl_jaas.config=software.amazon.msk.auth.iam.IAMLoginModule required; \ - --apiary.messaging.client.sasl.client.callback.handler.class=software.amazon.msk.auth.iam.IAMClientCallbackHandler + --apiary.messaging.consumer.security.protocol=SSL \ + --apiary.messaging.consumer.sasl.mechanism=AWS_MSK_IAM \ + --apiary.messaging.consumer.sasl_jaas.config=software.amazon.msk.auth.iam.IAMLoginModule required; \ + --apiary.messaging.consumer.sasl.client.callback.handler.class=software.amazon.msk.auth.iam.IAMClientCallbackHandler ## Metrics diff --git a/drone-fly-app/src/main/java/com/expediagroup/dataplatform/dronefly/app/context/CommonBeans.java b/drone-fly-app/src/main/java/com/expediagroup/dataplatform/dronefly/app/context/CommonBeans.java index 63c1796..13b4a0b 100644 --- a/drone-fly-app/src/main/java/com/expediagroup/dataplatform/dronefly/app/context/CommonBeans.java +++ b/drone-fly-app/src/main/java/com/expediagroup/dataplatform/dronefly/app/context/CommonBeans.java @@ -19,7 +19,6 @@ import java.util.Properties; import java.util.stream.Collectors; -import org.apache.commons.lang3.StringUtils; import org.apache.hadoop.hive.conf.HiveConf; import org.apache.hadoop.hive.metastore.MetaStoreEventListener; import org.apache.hadoop.hive.metastore.api.MetaException; @@ -40,7 +39,7 @@ @Configuration public class CommonBeans { private static final Logger log = LoggerFactory.getLogger(CommonBeans.class); - public static final String PREFIX = "apiary.messaging.client."; + public static final String PREFIX = "apiary.messaging.consumer"; @Value("${instance.name:drone-fly}") private String instanceName; @@ -77,7 +76,7 @@ public ListenerCatalog listenerCatalog(HiveConf conf) throws MetaException { @Bean public MessageReaderAdapter messageReaderAdapter() { - Properties clientProperties = getClientProperties(); + Properties clientProperties = getConsumerProperties(); KafkaMessageReader delegate = KafkaMessageReaderBuilder. builder(bootstrapServers, topicName, instanceName). withConsumerProperties(clientProperties). @@ -85,16 +84,13 @@ public MessageReaderAdapter messageReaderAdapter() { return new MessageReaderAdapter(delegate); } - private Properties getClientProperties() { - Properties clientProperties = new Properties(); + private Properties getConsumerProperties() { + Properties consumerProperties = new Properties(); getEnvProperties().forEach((key, value) -> { - if (key.toString().startsWith(PREFIX)) { - String keyWithoutPrefix = StringUtils.replace(key.toString(), PREFIX, ""); - clientProperties.put(keyWithoutPrefix, value.toString()); - log.info("Client property {} set with value: {}", keyWithoutPrefix, value); - } + consumerProperties.put(key.toString(), value.toString()); + log.info("Client property {} set with value: {}", key, value); } ); - return clientProperties; + return consumerProperties; } } \ No newline at end of file