예제 #1
0
        public void Publish(string queueName, string message)
        {
            var factory = new RabbitMQConnection(
                new RabbitMQConnectionDetail()
            {
                HostName = "localhost", UserName = "******", Password = "******"
            }
                );

            using (var connection = factory.CreateConnection())
                using (var channel = connection.CreateModel())
                {
                    var rabbitMQHelper = new RabbitMQHelper(channel, "");
                    rabbitMQHelper.SetupQueue(queueName);
                    rabbitMQHelper.PushMessageIntoQueue(Encoding.UTF8.GetBytes(message), queueName);
                }
        }
예제 #2
0
        public void Consume(string queueName)
        {
            var factory = new RabbitMQConnection(
                new RabbitMQConnectionDetail()
            {
                HostName = "localhost", UserName = "******", Password = "******"
            }
                );

            using (var connection = factory.CreateConnection())
                using (var channel = connection.CreateModel())
                {
                    var rabbitMQHelper = new RabbitMQHelper(channel, "");

                    var readMsg = rabbitMQHelper.ReadMessageFromQueue(queueName);

                    string resultString = System.Text.Encoding.UTF8.GetString(readMsg, 0, readMsg.Length);
                    _messageProcessor.ProcessMessage(resultString);
                }
        }