概念
1、AMQP:Advanced Message Queuing Protocol,是一個(gè)提供統(tǒng)一消息服務(wù)的應(yīng)用層標(biāo)準(zhǔn)協(xié)議。
2、IPC(單一系統(tǒng)進(jìn)程間通信) -> socket(不同機(jī)器間進(jìn)程通信) -> AMQP(解決大型系統(tǒng)模塊與組件間通信)
3、RabbitMQ 基于 Erlang 開(kāi)發(fā),是 AMQP 的一個(gè)開(kāi)源實(shí)現(xiàn)。
4、RabbitMQ 系統(tǒng)架構(gòu)圖:
5、名詞術(shù)語(yǔ):
RabbitMQ Server(broker server):維護(hù)一條從 Producer 到 Consumer 的路線,保證數(shù)據(jù)能夠按照指定的方式進(jìn)行傳輸;
Client A & B:數(shù)據(jù)發(fā)送方,Producers create messages and publish (send) them to a broker server (RabbitMQ),一個(gè)有效的 Message 包含 payload 和 label 兩部分
Client 1、2、3:數(shù)據(jù)消費(fèi)方,Consumers attach to a broker server (RabbitMQ) and subscribe to a queue
Exchange:Exchanges are where producers publish their messages
Queue: Queues are where the messages end up and are received by consumers
Binding:Bindings are how the messages get routed from the exchange to particular queues
還有幾個(gè)隱式的概念:Connection:Producer 和 Consumer 通過(guò) TCP 連接到 RabbitMQ
Channel:它建立在上述的 TCP 連接中,數(shù)據(jù)流動(dòng)都是在 Channel 中進(jìn)行的
此外,Exchanges 分三種類(lèi)型:direct:如果 routing key 匹配,那么 Message 就會(huì)被傳遞到相應(yīng)的 queue
fanout:會(huì)向響應(yīng)的 queue 廣播
topic:對(duì) key 進(jìn)行模式匹配,比如 ab* 可以傳遞到所有 ab* 的 queue