Ejemplo n.º 1
0
        public bool queue(Transaction transaction)
        {
            try
            {
                KafkaProducerRepository kafkaProducerRepository = new KafkaProducerRepository();
                kafkaProducerRepository.Create("decline_simple", JsonConvert.SerializeObject(transaction));

                return(true);
            }
            catch (Exception ex)
            {
                Console.WriteLine($"Exception is: {ex.Message}");
                return(false);
            }
        }
Ejemplo n.º 2
0
        private static void Produce()
        {
            KafkaProducerRepository KafkaRepo = new KafkaProducerRepository();

            var Router = InitDefaultConfig();
            var Client = new Producer(Router);

            List <Message> Messages = new List <Message>();

            foreach (KafkaProducerMessage message in KafkaRepo.GetKafkaProducerMessageByTopic(Topic))
            {
                Messages.Add(new Message(message.MessageContent));
                KafkaRepo.ArchiveKafkaProducerMessage(message.KafkaProducerMessageID);
            }

            Client.SendMessageAsync(Topic, Messages).Wait();

            KafkaRepo.Dispose();
        }