Beispiel #1
0
        private static void ConnectToKafka()
        {
            string KafkaURL = config["Kafka:kafkaURL"];

            Console.WriteLine($"Kafka URL : {KafkaURL}");

            producer = MessageProducer.GetInstance;
            var producerConfig = new Dictionary <string, object> {
                { "bootstrap.servers", KafkaURL }
            };

            producer.SetupProducer(producerConfig);


            var consumer         = MessageConsumer.GetInstance;
            var subscriberConfig = new Dictionary <string, object> {
                { "group.id", Literals.KAFKA_CONSUMER_GROUP_MQTT_ADAPTER },
                { "bootstrap.servers", KafkaURL }
            };

            consumer.SetupConsumer(subscriberConfig);
            Task.Run(() => consumer.SubscribeTopics(new List <string> {
                Literals.KAFKA_TOPIC_CONFIG
            }, SendMessageToClient));
        }