public void ProduceMessageString(string queueName, string message) { using (var connection = _messageQueueServer.CreateServer()) { using (var channel = connection.CreateModel()) { channel.QueueDeclare(queueName, false, false, false, null); channel.BasicPublish("", queueName, null, Encoding.UTF8.GetBytes(message)); } } }
public string ConsumeMessages(string queueName) { BasicGetResult data; using (var connection = _messageQueueServer.CreateServer()) using (var channel = connection.CreateModel()) { channel.QueueDeclare(queueName, false, false, false, null); data = channel.BasicGet(queueName, true); } return(data != null?Encoding.UTF8.GetString(data.Body) : null); }