Message Queuing Learning Record

Because message queues are used in the project, questions about ActiveMQ may be asked in the interview

  1. Application scenario
    1. Asynchronous processing: such as SMS notification, terminal status push, App push, user registration, etc.

    1. Data synchronization: business data push synchronization
      3. Retry compensation: retry after accounting failure

    2. System decoupling : communication uplink and downlink, terminal exception monitoring, distributed event
      center
      : Log service, monitoring and reporting
  2. concept

    1. The concept of Broker
      Broker comes from Apache ActiveMQ, which is the MQ server in layman's terms.
  3. Message producer and consumer
    Message producer Producer: Send messages to the message queue.
    Message consumer Consumer: Receive messages from the message queue.
  4. The hierarchy of messages
    (1) Topic is a type of topic
    (2) Each message contains multiple partitions, partitions are stored on different brokers, and each partition has multiple replicas (copy) [Partition defaults to each message has 2 partitions , To create a topic, you can specify the number of partitions. There are 100 million rows in one day and can be divided into 8 partitions. If there are hundreds of thousands of rows per day, just one partition (here refers to kafka)]
    (3) Message is each message

  5. Message queue mode
    1) Point-to-point mode The
    message producer produces messages and sends them to the queue, and then the message consumers take them out of the queue and consume the messages. After the message is consumed, there is no more storage in the queue, so it is impossible for the message consumer to consume the message that has been consumed. Queue supports the existence of multiple consumers, but for a message, only one consumer can consume it.

    2) Publish-Subscribe Mode A
    message producer (publish) publishes a message to a topic, and multiple message consumers (subscription) consume the message at the same time. Unlike the peer-to-peer approach, messages published to a topic are consumed by all subscribers.

    Note : Publish-subscribe mode that supports subscription groups

  6. If the message queue is down
    Persistence (save to file, save to database), multiple nodes to backup

5. How kafka implements load balance & HA
1) The producer sends messages to the specified partition according to the algorithm specified by the user
2) There are multiple partitions, each partition has multiple replica replicas, and each replica is distributed on different broker nodes
3) Each partition needs to select the lead partition, the leader partition is responsible for reading and writing, and the zookeeper is responsible for fail over fast failure
4) The dynamic joining and leaving of brokers and consumers are managed by zookeeper

6. Kafka expansion
When it is necessary to increase the broker node, the new broker will register with zookeeper, and the producer and consumer will perceive these changes according to the watcher on zookeeper and make adjustments in time

7. ActiveMq guarantees high availability
zookeeper + levelDB

Reference:
1. http://blog.csdn.net/heyutao007/article/details/50131089
2. https://www.cnblogs.com/tianqing/p/7110468.html
3. https://www.cnblogs. com/oftenlin/p/4045924.html

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325601461&siteId=291194637