2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2023 Nordix Foundation. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.onap.dmaap.kafka;
23 import java.util.List;
24 import org.apache.kafka.common.KafkaException;
26 public interface IKafkaConfig {
29 * Returns the list of kafka bootstrap servers.
31 * @return List of kafka bootstrap servers.
33 List<String> getKafkaBootstrapServers();
36 * Kafka security protocol to be used by the client to Auth towards the kafka cluster
38 * @return Kafka security.protocol. Default is SASL_PLAINTEXT in the current onap kafka config
40 default String getKafkaSecurityProtocolConfig() {
41 return "SASL_PLAINTEXT";
45 * Kafka SASL mechanism to be used by the client to Auth towards the kafka cluster
47 * @return Kafka sasl.mechanism. Default is SCRAM-SHA-512 in the current onap kafka config
49 default String getKafkaSaslMechanism() {
50 return "SCRAM-SHA-512";
54 * Kafka JAAS config to be used by the client to Auth towards the kafka cluster.
55 * If overridden, must align with sasl.jaas.config convention set out by the sasl.mechanism being used
56 * otherwise, mandatory setting of the environment variable SASL_JAAS_CONFIG is required to provide default behaviour
57 * @return Kafka sasl.jaas.config
59 default String getKafkaSaslJaasConfig() {
60 String saslJaasConfFromEnv = System.getenv("SASL_JAAS_CONFIG");
61 if(saslJaasConfFromEnv != null) {
62 return saslJaasConfFromEnv;
64 throw new KafkaException("sasl.jaas.config not set for Kafka Consumer");
69 * The timeout in seconds to wait for a response from each poll.
71 * @return Client Timeout in seconds. Default is 10 seconds
73 default int getPollingTimeout() {
78 * Returns the kafka consumer group defined for this component.
80 * @return KafkaConsumer group.
82 String getConsumerGroup();
85 * Returns the kafka consumer id defined for this component.
87 * @return KafkaConsumer id or null.
89 String getConsumerID();
92 * Returns a list of kafka topics to consume from.
94 * @return List of kafka topics or empty.
96 List<String> getConsumerTopics();
99 * Returns a list of kafka topics to produce to.
101 * @return List of kafka topics or empty.
103 List<String> getProducerTopics();