public override void Publish(string message, string exchangeName, string routingKey, IBasicProperties messageProperties = null) { if (!IsConnected) { Connect(); } using (var channel = _connection.CreateModel()) { var payload = Encoding.UTF8.GetBytes(message); channel.BasicPublish(exchangeName, routingKey, messageProperties ?? RabbitMQProperties.CreateDefaultProperties(channel), payload); } }
public override void Publish(string message, string queueName, bool createQueue = true, IBasicProperties messageProperties = null, IDictionary <string, object> queueArgs = null) { if (!IsConnected) { Connect(); } using (var channel = _connection.CreateModel()) { if (createQueue) { channel.QueueDeclare(queueName, true, false, false, queueArgs); } var payload = Encoding.UTF8.GetBytes(message); channel.BasicPublish(string.Empty, queueName, messageProperties ?? RabbitMQProperties.CreateDefaultProperties(channel), payload); } }