示例#1
0
        public void MessageProducerService(NewMessage message)
        {
            try
            {
                var producer = new Ninject.Parameters.ConstructorArgument("producer", new ProducerBuilder <Null, string>(new ProducerConfig
                {
                    BootstrapServers = jsonHandle.JsonKey("ConsumerConfigure.BootstrapServers")
                }).Build());

                //var producer = new Ninject.Parameters.ConstructorArgument("producer", kernel.Get<IProducer<Null,string>>());
                var topic = new Ninject.Parameters.ConstructorArgument("topic", jsonHandle.JsonKey("ProducerConfigure.Topic"));
                eventProducer = kernel.Get <EventProducer>(producer, topic);


                var newMessage = mapper.Map <NewMessage, Message>(message);


                eventProducer.Send(newMessage);

                logger.Information("Dados Enviados");
            }
            catch (ProduceException <Null, string> ex)
            {
                logger.Error(ex.ToString());
            }
            catch (Exception ex)
            {
                logger.Error(ex.ToString());
            }
        }
示例#2
0
        static void Main(string[] args)
        {
            kernel     = new StandardKernel(new DIContainer());
            jsonHandle = kernel.Get <JsonHandle>();

            ProducerTimer = Int32.Parse(jsonHandle.JsonKey("ProducerTimer"));
            ConsumerTimer = Int32.Parse(jsonHandle.JsonKey("ConsumerTimer"));
            identificador = jsonHandle.JsonKey("Identificador");

            appMessage = kernel.Get <AppMessageService>();

            thread = new Thread[] { new Thread(new ThreadStart(ThreadProducer))
                                    {
                                        Priority = ThreadPriority.Highest
                                    }, new Thread(new ThreadStart(ThreadConsumer))
                                    {
                                        Priority = ThreadPriority.Lowest
                                    } };

            thread[0].Start();

            thread[1].Start();

            key = new ConsoleKeyInfo();
            key = Console.ReadKey();



            //Console.WriteLine("Hello World!");
        }
 public void SetUp()
 {
     kernel        = new StandardKernel(new DIContainer());
     jsonHandle    = kernel.Get <JsonHandle>();
     identificador = jsonHandle.JsonKey("Identificador");
     //appMessage = kernel.Get<AppMessageService>();
 }