Add default fetch timeout for kafka client 42/136842/1
authorrameshiyer27 <ramesh.murugan.iyer@est.tech>
Wed, 13 Dec 2023 15:35:58 +0000 (15:35 +0000)
committerrameshiyer27 <ramesh.murugan.iyer@est.tech>
Thu, 14 Dec 2023 11:02:13 +0000 (11:02 +0000)
Issue-ID: POLICY-4201
Signed-off-by: zrrmmua <ramesh.murugan.iyer@est.tech>
Change-Id: I494f2bd9e02edf61e8a8a199018356cd162e0d45

policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/IndexedKafkaTopicSourceFactory.java

index 45a8be3..1d586e4 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * ============LICENSE_START=======================================================
- * Copyright (C) 2022 Nordix Foundation.
+ * Copyright (C) 2022-2023 Nordix Foundation.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -96,6 +96,8 @@ class IndexedKafkaTopicSourceFactory implements KafkaTopicSourceFactory {
                 .servers(servers)
                 .topic(topic)
                 .managed(true)
+                .fetchTimeout(PolicyEndPointProperties.DEFAULT_TIMEOUT_MS_FETCH)
+                .fetchLimit(PolicyEndPointProperties.DEFAULT_LIMIT_FETCH)
                 .useHttps(false).build());
     }
 
@@ -117,6 +119,15 @@ class IndexedKafkaTopicSourceFactory implements KafkaTopicSourceFactory {
         }
 
         var kafkaTopicSource = this.build(KafkaPropertyUtils.makeBuilder(props, topic, servers)
+                .consumerGroup(props.getString(
+                        PolicyEndPointProperties.PROPERTY_TOPIC_SOURCE_CONSUMER_GROUP_SUFFIX, null))
+                .consumerInstance(props.getString(
+                        PolicyEndPointProperties.PROPERTY_TOPIC_SOURCE_CONSUMER_INSTANCE_SUFFIX, null))
+                .fetchTimeout(props.getInteger(
+                        PolicyEndPointProperties.PROPERTY_TOPIC_SOURCE_FETCH_TIMEOUT_SUFFIX,
+                        PolicyEndPointProperties.DEFAULT_TIMEOUT_MS_FETCH))
+                .fetchLimit(props.getInteger(PolicyEndPointProperties.PROPERTY_TOPIC_SOURCE_FETCH_LIMIT_SUFFIX,
+                        PolicyEndPointProperties.DEFAULT_LIMIT_FETCH))
                 .build());
 
         newKafkaTopicSources.add(kafkaTopicSource);