rabbitmq explain

It is an application communication method according to the application. Application to communicate via a message (data for the application program) read out of the queue, without the need for a dedicated connection to link them.

Refers to message passing communication between a program in the data message transmitted by, rather than through direct calls to communicate with each other, is a technique commonly called directly, such as remote procedure calls. It refers to the application queue by the queue to communicate. Removed using a queue and transmission requirements received concurrently executing applications.

It refers to the application queue by the queue to communicate. Removed using a queue and transmission requirements received concurrently executing applications.
Two, AMQP namely Advanced Message Queuing Protocol
Advanced Message Queuing Protocol, is an open standard application layer protocol for message-oriented middleware design. Message middleware mainly for decoupling between the components, sender of the message without knowing the user's presence information, and vice versa.

AMQP main feature is a message for the queue, the routing (including point and publish / subscribe), reliability and safety.
Three, Rabbitmq concept:
       belonging to a popular open source message queuing systems. Belonging to the AMQP (Advanced Message Queuing Protocol) to achieve a standard. It is an open standard application-layer protocol for message-oriented middleware design. In a distributed system for store and forward messages, in terms of ease of use, scalability, high availability, and so doing well.
       Message middleware mainly for decoupling between the components, sender of the message without knowing the user's presence information, and vice versa.
       AMQP main feature is a message for the queue, the routing (including point and publish / subscribe), reliability and safety.

       RabbitMQ Features:
    use written in Erlang
    support persistence
    support HA
    provides C #, erlang, java, perl , python, ruby etc. development client terminal
four, what is coupled, decoupled
a coupling
1, coupling refers to two or more system or between two forms of movement as well as the impact of the phenomenon together by interacting with each other.

2, in software engineering, is the degree of coupling between objects dependencies between objects. The higher the coupling between objects, higher maintenance costs, so the design should minimize the object class and the coupling between the member.

3, Classification: coupling between the coupling, as well as hardware and software between the software modules. Coupling is a measure of the program structure of the linkages between the various modules. It depends on the complexity of the interface between each module, the calling module and what information the way through the interface.

Second, decoupling
1, decoupling, literally means to decouple the relationship.

2, in software engineering, i.e. to reduce the degree of coupling can be understood as decoupling, dependent relationship must exist between the coupling module, coupled to the theoretical absolute zero is impossible, but can be identified by conventional methods to reduce the degree of coupling to a minimum.

3, the design of the core idea: to minimize coupling of code, if the code is coupled found, it is necessary to take decoupling technology. Let data model, business logic and views between the three lower display coupled to one another, the association relies to a minimum, and thus will not affect the situation as a whole. A principle feature of the code is not written in the function code B, if needed interaction between the two, through the interface, through a message, or even the introduction of the framework, but in short, is not to write directly cross.
Fifth, the concept of the term RabbitMQ
Broker: Message Queue Server is simply an entity.
Exchange: Message switch that specifies what the message according to the rules, which are routed to a queue.
Queue: vector message queue, each message will be put into one or more queues. ? Binding: binding, its role is to exchange routing and queue bind in accordance with the rules.
Routing Key: routing keywords, exchange of messages delivered in accordance with this keyword.
vhost: web hosting, where a broker can offer more vhost, as a different user privilege separation.
producer: news producer, is the program delivered the message.
consumer: consumer news, is that the program accepts messages.
channel: message channels, in each client's connection can create multiple channel, each channel representing a conversation task?.
Six, work management RabbitMQ
MQ consumption - a model representative of typical producer, end to continue to write messages in the message queue, and the other end can be read or subscribe to messages in the queue. MQ is a concrete follow AMQP protocol implementations and products. In the project, without some return immediately extracted and time-consuming operation, made asynchronous processing, and this processing asynchronous requests greatly saving server response time, thereby increasing the throughput of the system.

 

( 1)客户端连接到消息队列服务器,打开一个channel。
( 2)客户端声明一个exchange,并设置相关属性。
( 3)客户端声明一个queue,并设置相关属性。
( 4)客户端使用routing key,在exchange和queue之间建立好绑定关系。
( 5)客户端投递消息到exchange。
( 6) exchange接收到消息后,就根据消息的key和已经设置的binding,进 行消息路由,将消息投递到一个或多个队列里

 

七、Rabbitmq 的 metadata
  元数据可以持久化在 RAM 或 Disc. 从这个角度可以把 RabbitMQ 集群中的节点分成两种 :RAM Node和 Disk Node.
       RAM Node 只会将元数据存放在RAM
       Disk node 会将元数据持久化到磁盘。 
   单节点系统就没有什么选择了 , 只允许 disk node, 否则由于没有数据冗余一旦重启就会丢掉所有的配置信息 . 但在集群环境中可以选择哪些节点是 RAM node.在集群中声明(declare) 创建 exchange queue binding, 这类操作要等到所有的节点都完成创建才会返回 : 
       如果是内存节点就要修改内存数据 , 
       如果是 disk node 就要等待写磁盘 , 节点过多这里的速度就会被大大的拖慢 .
    有些场景 exchang queue 相当固定 , 变动很少 ,那即使全都是 disc node, 也没有什么影响 . 如果使用 Rabbitmq 做 RPC( RPC :Remote Procedure Call—远程过程调用),  RPC 或者类似 RPC 的场景这个问题就严重了 , 频繁创建销毁临时队列 , 磁盘读写能力就很快成为性能瓶颈了。所以 , 大多数情况下 , 我们尽量把 Node 创建为RAM Node. 这里就有一个问题了 , 要想集群重启后元数据可以恢复就需要把集群元数据持久化到磁盘 , 那需要规划 RabbitMQ 集群中的 RAM Node 和 Disc Node 。

    只要有一个节点是 Disc Node 就能提供条件把集群元数据写到磁盘 ,RabbitMQ 的确也是这样要求的 : 集群中只要有一个 disk node 就可以 , 其它的都可以是 RAM node. 节点加入或退出集群一定至少要通知集群中的一个 disk node 。
    如果集群中 disk node 都宕掉 , 就不要变动集群的元数据 . 声明 exchange queue 修改用户权限 , 添加用户等等这些变动在节点重启之后无法恢复 。

    有一种情况要求所有的 disk node 都要在线情况在才能操作 , 那就是增加或者移除节点 .RAM node 启动的时候会连接到预设的 disk node 下载最新的集群元数据 . 如果你有两个 disk node(d1 d2), 一个 RAM node 加入的时候你只告诉 d1, 而恰好这个 RAM node 重启的时候 d1 并没有启动 , 重启就会失败 . 所以加入 RAM 节点的时候 , 把所有的disk node 信息都告诉它 ,RAM node 会把 disk node 的信息持久化到磁盘以便后续启动可以按图索骥 .

Guess you like

Origin www.cnblogs.com/itzhao/p/11330639.html
Recommended