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); } }
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); } }