RABBITMQ Learning: (vi) Direct Exchange (paste + my comments)

Source: Internet
Author: User
Tags rabbitmq

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 ();
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.