Beispiel #1
0
        private async Task DoWork(CancellationToken stoppingToken)
        {
            const string topic = "build.workshop.something";

            using (var producer = _producerFactory.Create())
            {
                await producer.ProduceAsync(topic : topic, message : new Message <string, string>()
                {
                    Key   = Guid.NewGuid().ToString(),
                    Value = $"kafka-the-basics is running. This message ID is {Guid.NewGuid().ToString()}"
                });
            }
        }
Beispiel #2
0
        private async Task DoWork(CancellationToken stoppingToken)
        {
            const string topic       = "build.workshop.something";
            var          newWorkshop = new WorkshopCreated
            {
                Id    = Guid.NewGuid().ToString(),
                Title = "Kafka - The basics",
                Date  = DateTime.Now.ToString("f")
            };

            using (var producer = _producerFactory.Create())
            {
                await producer.ProduceAsync(topic : topic, message : new Message <string, string>()
                {
                    Key   = Guid.NewGuid().ToString(),
                    Value = MessagingHelper.MessageToEnvelope(newWorkshop, "workshop_created", Guid.NewGuid().ToString())
                });
            }
        }