Exemple #1
0
        protected override void OnStart(string[] args)
        {
            Task.Factory.StartNew(async() =>
            {
                var dir        = AppDomain.CurrentDomain.BaseDirectory;
                var myProducer = new MyProducer("10.0.0.6:9092", "MyTopic", $"{dir}\\kafka.log", $"{dir}\\app.log");
                int i          = 1;
                while (true)
                {
                    await myProducer.SendMessage(i.ToString());

                    i++;
                    await Task.Delay(5000);
                }
            });
        }
Exemple #2
0
        static async Task Main(string[] args)
        {
            var dir        = AppDomain.CurrentDomain.BaseDirectory;
            var myProducer = new MyProducer("10.0.0.6:9092", "MyTopic", $"{dir}\\kafka.log", $"{dir}\\app.log");
            int i          = 1;

            Console.WriteLine("Sending message, please check out the log file. Press CTRL+C to exit.");
            while (true)
            {
                await myProducer.SendMessage(i.ToString());

                i++;
                await Task.Delay(5000);

                ;
            }
        }