1.首先需要下载.net下的驱动类。rabbitmq.client.dll.安装后可以使用提供的文档。当然也可以直接从别的地方只下载rabbitmq.client.dll使用。
下载地址:http://www.rabbitmq.com/dotnet.html
文档和安装程序都有了。
2.然后建立项目导入引用
一、首先建立一个消息的发送者类Sender
using System; using System.Collections.Generic; using System.Linq; using System.Text; using RabbitMQ.Client; using RabbitMQ.Client.Content; using System.Collections; namespace Sender { /// <summary> /// 向队列中写入一个消息 /// </summary> public class ProduceMQ { static void Main(string[] args) { //服务器所在的主机ip Uri uri = new Uri("amqp://192.168.1.99:8688/"); string exchange = "routing";//路由 string exchangeType = "direct";//交换模式 string routingKey = "rk";//路由关键字