读书人

Introduction to the AMQP 零-9-1 Mod

发布时间: 2013-11-09 17:06:53 作者: rapoo

Introduction to the AMQP 0-9-1 Model


About This Guide

This guide explains the AMQP 0-9-1 model used by RabbitMQ. The?original version?was written and kindly contributed by?Michael Klishin?and edited by?Chris Duncan.

High-level Overview of AMQP 0-9-1 and the AMQP ModelWhat is AMQP?

AMQP (Advanced Message Queuing Protocol) is a networking protocol that enables conforming client applications to communicate with conforming messaging middleware brokers.

Brokers and Their Role

brokers 从producers(产生消息的应用)接收消息然后转发给consumers(处理消息的应用)。

AMQP 0-9-1 Model in Brief

The AMQP 0-9-1 Model has the following view of the world: messages are published by producers to?exchanges, which are often compared to post offices or mailboxes. Exchanges then distribute message copies to?queues?using rules called?bindings. Then AMQP brokers either deliver messages to consumers subscribed to queues, or consumers fetch/pull messages from queues on demand.

Introduction to the AMQP 零-9-1 Model

When publishing a message, producers may specify various?message attributes?(message meta-data). Some of this meta-data may be used by the broker, however, the rest of it is completely opaque to the broker and is only used by applications that receive the message.

Networks are unreliable and applications may fail to process messages therefore the AMQP model has a notion of?message acknowledgements: when a message is delivered to a consumer the consumer?notifies the broker, either automatically or as soon as the application developer chooses to do so. When message acknowledgements are in use, a broker will only completely remove a message from a queue when it receives a notification for that message (or group of messages).

In certain situations, for example, when a message cannot be routed, messages may be?returned?to producers, dropped, or, if the broker implements an extension, placed into a so-called "dead letter queue". Producers choose how to handle situations like this by publishing messages using certain parameters.

Queues, exchanges and bindings are collectively referred to as?AMQP entities.

AMQP is a Programmable Protocol

AMQP 0-9-1 is a programmable protocol in the sense that AMQP entities and routing schemes are defined by applications themselves, not a broker administrator. Accordingly, provision is made for protocol operations that declare queues and exchanges, define bindings between them, subscribe to queues and so on.

?

这给应用程序开发者带来了极大的自由,但同时他们也应该注意到潜在的定义冲突。实际上,定义冲突很少发生,一旦发生通常意味着错误的配置。应用定义了所需要的AMQP实体好必要的路由schema,并可能在不需要的时候删除它们。

?

Exchanges and Exchange Types


Exchanges是一种AMQP实体,它是消息的发送对象。它接收消息并路由给零个或者多个queue。所使用的路由机制,依赖于exchange的类型和规则,又叫binds。 AMQP 0-9-1提供了四种exchange类型:

?

?

NameDefault pre-declared namesDirect exchange(Empty string) and amq.directFanout exchangeamq.fanoutTopic exchangeamq.topicHeaders exchangeamq.match (and amq.headers in RabbitMQ)

?

除了类型,exchanges还定义了一些属性,最重要的属性包括:

读书人网 >互联网

热点推荐