本文章介绍了在C#编程环境中使用RabbitMQ进行消息的发送和接收的基本方法和技术,帮助开发者快速掌握其核心功能。
```java
ch.ExchangeDeclare(exchange, exchangeType); // direct类型必须要有routingKey
ch.QueueDeclare(q, true, false, false, null); // 声明一个队列
// ch.QueueBind(q, exchange, routingKey);
ch.ExchangeDeclare(fanoutE, fanout); // 声明一个交换机
ch.QueueDeclare(fanoutQ, true, false, false, null); // 声明一个队列
// ch.QueueBind(q, fanoutE, routingKey);
ch.QueueBind(fanoutQ, fanoutE, fanoutk); // fanout模式下publish时不需要routingKey,所有绑定的队列都能接收到消息。
```