Exemplo n.º 1
0
        public Publisher(string queueName, string message)
        {
            _rabbitMQService = new RabbitMQService();


            using (var connection = _rabbitMQService.GetRabbitMQConnection())
            {
                using (var chanel = connection.CreateModel())
                {
                    chanel.QueueDeclare(queueName, false, false, false, null);
                    chanel.BasicPublish("", queueName, null, Encoding.UTF8.GetBytes(message));

                    Console.WriteLine("{0} queue su üzerine,\"{1}\"mesajı yazıldı", queueName, message);
                }
            }
        }
Exemplo n.º 2
0
        public Consumer(string queueName)
        {
            _rabbitMQService = new RabbitMQService();

            var connection = _rabbitMQService.GetRabbitMQConnection();
            {
                var channel = connection.CreateModel();
                {
                    var consumer = new EventingBasicConsumer(channel);
                    consumer.Received += (model, ea) =>
                    {
                        var body   = ea.Body;
                        var _queue = Encoding.UTF8.GetString(body);


                        this._queue = _queue;
                    };

                    channel.BasicConsume(queueName, false, consumer);
                    //Console.ReadLine();
                }
            }
        }