from:http://lostechies.com/derekgreer/2012/04/02/rabbitmq-for-windows-direct-exchanges/
RABBITMQ for windows:direct exchanges Posted by Derek Greer on April 2, 2012
This is the fifth installment to the SERIES:RABBITMQ for Windows. In the last installment, we took a look at the four exchange types provided by Rabbitmq:direct, Fanout, Topic, and Header S. In this installment we'll walk through a example which uses a direct exchange type directly and we ' ll take a look at The push API.
In the Hello world example from the second installment of the series, we used a direct exchange type implicitly by taking Advantage of the automatic binding of queues to the default Exchange using the ' queue name as the ' routing key. The example we'll work through this time would be similar, but we ' ll declare and bind to the exchange explicitly.
This time we example'll be a distributed logging application. We ll Create a Producer console application which publishes a logging message for some noteworthy action and a Consumer co Nsole application which displays the message to the console.
Puncha: The author of the previous 5 posts, very simple, see I am flowing ~, but see this post, let me confused to study for 2 hours, this has a RABBITMQ learning Chapter one. I don't think the example of this article is a good example. The author's intention is obvious, because Directexchange is too simple, no depth, so he staggered a basicconsumer function (block call), but the simple problem is complicated. and confusing some concepts, I'll explain here:
1. Exchange is used only for Producer,routingkey to bind Exchange and queue, which is generally done on the producer side, but the author is on the consumer side. It can be, but the author should add a note.
2. The author's usage illustrates a problem if producer sends messages to exchange messages that are not bound to the queue.
3. The author let me have a deep understanding of RMQ, hehe.
Beginning with our Producer app, we'll start by establishing a connection using the default settings, create the Connectio N, and create a channel:
Using Rabbitmq.client;
Namespace Producer
{
class program
{
static void Main (string[] args)
{
var conne Ctionfactory = new ConnectionFactory ();
Iconnection connection = Connectionfactory.createconnection ();
Imodel channel = connection. Createmodel ();
}