public CounterKafkaService(CafeDatabaseSettings cafeDatabaseSettings, CafeKafkaSettings cafeKafkaSettings) { try { _consumerConfig = KafkaConfig.CreateConsumerConfig(cafeKafkaSettings); _producerConfig = KafkaConfig.CreateProducerConfig(cafeKafkaSettings); Console.WriteLine(DateTime.Now + " - Read Kafka Bootstrap: " + cafeKafkaSettings.BootstrapServers); } catch (Exception ex) { Console.WriteLine("Exception in kafka settings: " + ex); } try { var client = new MongoClient(cafeDatabaseSettings.ConnectionString); var database = client.GetDatabase(cafeDatabaseSettings.DatabaseName); _orderRepository = database.GetCollection <Order>(cafeDatabaseSettings.OrdersCollectionName); Console.WriteLine(DateTime.Now + " - Read MongoDB Connection String: " + cafeDatabaseSettings.ConnectionString); Console.WriteLine(DateTime.Now + " - Read MongoDB DB Name: " + cafeDatabaseSettings.DatabaseName); Console.WriteLine(DateTime.Now + " - Read MongoDB Collection Name: " + cafeDatabaseSettings.OrdersCollectionName); } catch (Exception ex) { Console.WriteLine("Exception in mongodb settings: " + ex); } }
public CounterKafkaService(CafeDatabaseSettings cafeDatabaseSettings, CafeKafkaSettings cafeKafkaSettings) { try { _consumerConfig = new ConsumerConfig() { GroupId = cafeKafkaSettings.GroupId, BootstrapServers = cafeKafkaSettings.BootstrapServers, AutoOffsetReset = AutoOffsetReset.Earliest, SocketKeepaliveEnable = true, AllowAutoCreateTopics = true }; _producerConfig = new ProducerConfig() { BootstrapServers = cafeKafkaSettings.BootstrapServers }; Console.WriteLine("Read Kafka Bootstrap: " + cafeKafkaSettings.BootstrapServers); } catch (Exception ex) { Console.WriteLine("Exception in kafka settings: " + ex); } try { var client = new MongoClient(cafeDatabaseSettings.ConnectionString); var database = client.GetDatabase(cafeDatabaseSettings.DatabaseName); _orderRepository = database.GetCollection <Order>(cafeDatabaseSettings.OrdersCollectionName); Console.WriteLine("Read MongoDB Connection String: " + cafeDatabaseSettings.ConnectionString); Console.WriteLine("Read MongoDB DB Name: " + cafeDatabaseSettings.DatabaseName); Console.WriteLine("Read MongoDB Collection Name: " + cafeDatabaseSettings.OrdersCollectionName); } catch (Exception ex) { Console.WriteLine("Exception in mongodb settings: " + ex); } }