//Declare queue name. This can be anything you like string QueueName = "QTransactions"; // Create a new connection factory for the queue var factory = new ConnectionFactory(); // Because Rabbit is installed locally, we can run it on localhost factory.HostName = "127.0.0.1"; using (IConnection connection = factory.CreateConnection()) using (IModel channel = connection.CreateModel()) { // mark all messages as persistent const bool durable = true; channel.QueueDeclare(QueueName, durable, false, false, null); // Set delivery mode (1 = non Persistent | 2 = Persistent) IBasicProperties props = channel.CreateBasicProperties(); props.DeliveryMode = 2; string msg = args[0]; byte[] body = System.Text.Encoding.UTF8.GetBytes(msg); channel.BasicPublish("", QueueName, props, body); Console.WriteLine(" [x] Sent {0}", msg); }