日期:2014-05-16 浏览次数:20525 次
RabbitMQ is a message broker. In essence, it accepts messages from producers, and delivers them to consumers. In-between, it can route, buffer, and persist the messages according to rules you give it.
RabbitMQ 是一个消息代理。说白了,它从“生产者”接收消息,并将这些消息发送给“消费者”。在这个过程中,它可以根据你给定的规则对消息进行路由、缓冲和持久化。
RabbitMQ, and messaging in general, uses some jargon.(常用术语)
Producing means nothing more than sending. A program that sends messages is a producer. We'll draw it like that, with "P":
A queue is the name for a mailbox. It lives inside RabbitMQ. Although messages flow through RabbitMQ and your applications, they can be stored only inside a queue. A queue is not bound by any limits, it can store as many messages
as you like - it's essentially an infinite buffer. Many producers can send messages that go to one queue - many consumers can try to receive data from one queue. A queue will be drawn like this, with its name above it:
Consuming has a similar meaning to receiving. A consumer is a program that mostly waits to receive messages. On our drawings it's shown with "C":
Note that the producer, consumer, and broker do not have to reside on the same machine; indeed in most applications they don't.
注意:生产者、消费者和消息代理(中间人)不是必须在一个机器上,确实如此,大多数应用程序都这样。
In this part of the tutorial we'll write two programs in PHP; a producer that sends a single message, and a consumer that receives messages and prints them out. We'll gloss over some of the detail in the php-amqplib API, concentrating on this very simple thing just to get started. It's a "Hello World" of messaging.