io.keyko.monitoring.preprocessing.TopicCreation Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of web3-event-streamer Show documentation
Show all versions of web3-event-streamer Show documentation
Kafka stream processors that enrich data generated with web3-monitoring agent
package io.keyko.monitoring.preprocessing;
import org.apache.kafka.clients.admin.AdminClient;
import org.apache.kafka.clients.admin.AdminClientConfig;
import org.apache.kafka.clients.admin.NewTopic;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
public class TopicCreation {
public static void createTopics(List topicNames, String kafkaServer) {
Properties props = new Properties();
props.put(AdminClientConfig.BOOTSTRAP_SERVERS_CONFIG, kafkaServer);
AdminClient a = AdminClient.create(props);
a.createTopics(convertToNewTopics(topicNames));
}
public static List convertToNewTopics(List topicNames) {
List topics = new ArrayList();
for (String i : topicNames) {
topics.add(new NewTopic(i, 1, (short) 1));
}
return topics;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy