没有绑定器,哪怕是最简单的消息,交换器也不能将其投递到队列中,只能抛弃它。
Without bindings the exchange would simply never deliver the message to a queue but just drop them.
接受和发送消息:交换器类型。
我们的例子中,fanout交换器不会解释任何东西:它只是将消息投递到所有绑定到它的队列中。
As our example already hinted the fanout exchange does not interpret anything at all: it delivers messages to all the queues bound to it.
如果Bob想和Alice成为朋友,他会使用这个队列的名字作为routingkey,发送一个消息到默认交换器。
If Bob wants to be friends with Alice he sends the default exchange a chat message using the name of the friendship queue as routing key.
然后它发送请求给一些交换器,在消息的reply - to字段中包含了之前声明的回复队列的名字。
Then it sends some request to some exchange and includes the name of the previously declared reply queue in the reply-to property of the message.
这使得可以将发送到不同交换器的具有不同routingkey(或者其他属性)的消息发送到同一个队列中。
This enables the routing of messages send to different exchanges with different routing keys (or other message properties) into a single queue.
客户端声明一个它想要发送消息的目的交换器,然后将消息传递给交换器。
The client declares the exchange it wants to send the message to and publishes the message to it.
客户端可以通过交换器的名字来发送消息,也可以通过队列的名字收取信息。
Knowing the name of an exchange grants a client the power to publish messages to it, knowing the name of a queue the capability to receive messages from it.
为了成为bob的好友,Alice首先得发送一个消息给fanout交换器iends,我们假设这个交换器是访问受限24的:普通用户不能够将队列绑定到它。
To become friends with a user Bob, user Alice sends a message to the fanout exchange iends. We assume that this exchange is somehow access restricted 24: ordinary users cannot bind queues to it.
交换器(Exchange),它是发送消息的实体。
The exchange which is the entity to which messages are sent.
交换器和队列之间的关系称之为捆绑。可以简单理解为:这个队列对这个特定的交换器的消息感兴趣。
A binding is a relationship between an exchange and a queue. This can be simply read as: the queue is interested in messages from this exchange.
如亲所见,建立连接后我们声明了一个交换器。因为发布消息到不存在的交换器是禁止的,所以这步是必须的。
As you see, after establishing the connection we declared the exchange. This step is necessary as publishing to a non-existing exchange is forbidden.
交换器必须清楚地知道如何处理收到的消息。
The exchange must know exactly what to do with a message it receives.
交换器必须清楚地知道如何处理收到的消息。
The exchange must know exactly what to do with a message it receives.
应用推荐