Skip to content

Instantly share code, notes, and snippets.

@redknitin
Created November 16, 2015 13:43
Show Gist options
  • Select an option

  • Save redknitin/a4b37282c2efb1bb9430 to your computer and use it in GitHub Desktop.

Select an option

Save redknitin/a4b37282c2efb1bb9430 to your computer and use it in GitHub Desktop.
.NET: Publish to RabbitMQ
ConnectionFactory connFac = new ConnectionFactory();
connFac.Uri = "amqp://user:pass@172.16.5.17:5672";
connFac.UserName = "user";
connFac.Password = "pass";
IConnection conn = connFac.CreateConnection();
IModel channel = conn.CreateModel();
channel.ExchangeDeclare("TaskNotify", ExchangeType.Direct);
channel.QueueDeclare("NewTask", false, false, true, null);
channel.QueueBind("NewTask", "TaskNotify", "Glowfish", null);
channel.BasicPublish("TaskNotify", "Glowfish", null, System.Text.Encoding.ASCII.GetBytes("Hello"));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment