[RocketMQ source learning] - 1. Getting Started

Why read RocketMQ

  1. Message Queuing more widely used in Internet applications, the study door she can make me a better understanding of the use of technology works

  2. Through her study of the source code, to broaden awareness

  3. RocketMQ Ali experienced a two-eleven

What nouns

  • Producer news producer, responsible for producing news

  • Consumer news consumers, responsible consumption messages

  • Producer Group a class set of name Producer, Producer typically sends such a message type, and the same transmission logic

  • Consumer Group A Class Consumer collection name, a class of consumer usually such Consumer message, logical and consistent consumption

  • The Push Consumer Consumer one, a register is usually applied to the Listener Interface Consumer objects, upon receipt of the message, the object stand Consumer Listener Interface engraved callback method. (Actively push the message to the Consumer)

  • The Pull Consumer Consumer an application typically calls Consumer active pull message from the Broker method pull message, the application control initiative. (Pull message from the Consumer)

  • Broker message transit role, responsible for storing messages, forward messages

  • NameServer responsible for the registration and management center monitor producers, consumers, Broker of

  • Topic news theme, a message type, to classify messages by Topic

  • Tag message label, two types of messages, a message classification to further distinguish at a Topic

  • Consumer Cluster All Consumer Group ID identified by a split evenly consume messages. Topic nine e.g. a message, a Consumer Group ID has three instances, the consumption patterns in each instance the cluster shared equally, consuming only three of these messages.

  • Broadcast Consumer a Group ID Consumer are all identified by a message each time the consumer. Topic nine e.g. a message, a Consumer Group ID has three instances, the consumption patterns in each instance will broadcast each message consumer 9.

  • Message sequence order of the message to be consistent with the consumption of the order of sending messages, in RocketMQ mainly refers to the partial sequence, i.e., a type of message to meet cis Rank, must be single-threaded Producer transmission order, and sent to the same queue, and consumer Producer can be sent in accordance with the order to consume news.

  • Common message sequence a sequential message, under normal circumstances, the order can ensure complete message, but when a communication abnormality occurs, Broker restart, and the queue the total number of changes, the queue after positioning vary modulo hash , generated short message sequence inconsistent. If the service can tolerate the cluster in exceptional cases (e.g., a Broker down or reboot), the short message is scrambled using the normal sequential way type suitable.

Code modules, module architecture FIG.

Project structure shown in Figure

 

 

Version 4.5.2

  • rocketmq-acl: access control (ACL) mainly RocketMQ provide Topic resource level user access control

  • rocketmq-broker: responsible for forwarding messages, producer receives and stores a message sent simultaneously pull message consumer here

  • rocketmq-client: contains the Producer and Consumer, is responsible for sending and receiving messages

  • rocketmq-common: enumeration constants common base class methods or data structures, described according to the target sub straightaway

  • rocketmq-distribution: Some sh scripts and configuration, mainly used in the deployment of

  • rocketmq-filter: a filter for filtering the server SQL92

  • rocketmq-logappender: integrated log4, log4j2, logback log

  • rocketmq-logging: providing factory class and method log

  • rocketmq-namesrv: registration centers, each broker will be registered here, client will get information broker here

  • rocketmq-openmassageing:

  • rocketmq-remoting: with Netty4 write client and server

  • rocketmq-store: storage services, message storage, indexing storage, commitLog storage

  • rocketmq-ools: command-line tool

RocketMQ deployment structure diagram

  • Name Server is a virtually stateless nodes, clusters can be deployed without any information synchronization between nodes.

  • Broker relatively complex deployment, Broker into Master and Slave, Master may correspond to a plurality of Slave, a Slave but corresponds to only one Master, Master and Slave in a correspondence relationship by specifying the same BrokerName, different BrokerId defined, BrokerId 0 represents Master, nonzero if Slave. Master can also deploy multiple. Each Broker Name Server build all nodes in the cluster long connection, the timing information to all registered Topic Name Server.

  • Producer 与 Name Server 集群中的其中一个节点(随机选择)建立长连接,定期从 Name Server 取 Topic 路 由信息,并向提供 Topic 服务的 Master 建立长连接,且定时向 Master 发送心跳。Producer 完全无状态,可集群部署。

  • Consumer 与 Name Server 集群中的其中一个节点(随机选择)建立长连接,定期从 Name Server 取 Topic 路由信息,并向提供 Topic 服务的 Master、Slave 建立长连接,且定时向 Master、Slave 发送心跳。Consumer 既可以从 Master 订阅消息,也可以从 Slave 订阅消息,订阅规则由 Broker 配置决定。

Guess you like

Origin www.cnblogs.com/milicool/p/11708224.html