kafka - preschool Information (message queue)

Message Queue Introduction

Message (Message): refers to the transfer of data between applications, a message can be very simple, for example, only contains the text string, may be more complex, and may contain embedded objects.

Message Queue (Message Queue): is communication between an application, the message can be returned immediately by the system to ensure reliable mail message information, the message just publishers publish messages to the MQ regardless of who take, message users simply take a message from the MQ whoever posted, so publishers and users do not know about each other.

 

Message Queuing application scenario

Comprising four message queues in the practical application scenarios:

Using Coupling : between multiple application processes the same message through the message queue, the call interface to avoid failure results in failure of the entire process;

Asynchronous processing : multi-application message queue for the same message is processed, concurrent processing of messages between applications, compared to serial processing, reduce processing time;

Limiting clipping : Widely used spike or buying activity and avoid excessive applications lead to hang;

Message driven system : The system is divided into the message queue, the message producers, the message consumer, the producer is responsible for generating messages, consumers (there may be more) responsible for processing the message;

 

Message Queue two modes

Message Queuing includes two modes, point to point mode (point to point, queue) and publish / subscribe model (publish / subscribe, topic)

1, ad-hoc mode

Ad-hoc mode includes three roles:

                                               message queue

                                               The sender (producer)

                                               Recipient (consumer)         

               

Message sender to the message queue of production, and then removed from the queue the message recipient and the message consumer. After the message is consumed, queue storage is no longer there, so the message recipient has been impossible to consumer consumption of news.

Point to Point mode features:

  • Each message has a recipient (Consumer) (i.e., once the consumer, the message is no longer in the message queue);
  • Between sender and receiver no dependencies, then the sender to send a message, whether or not the recipient is running, will not affect the next time to send a message to the sender;
  • Upon successful reception of the message recipient needs to reply to the success of the queue, the message queue in order to delete the currently received message;

 

2 , publish / subscribe model

Publish / subscribe model includes three roles under:

                                                     Role topic (Topic)

                                                     Publisher (Publisher)

                                                     Subscribers (Subscriber)

           

Posted by sending a message to the Topic, the system will deliver these messages to multiple subscribers.

Publish / subscribe model features:

  • Each message may have a plurality of subscribers;
  • There are dependent on the time between publishers and subscribers. After for a theme (Topic) subscribers, it must create a subscriber, the message to the consumer publisher.
  • In order to consume messages, subscribers need to subscribe in advance the character theme, and keep the line running;
Published 85 original articles · won praise 174 · Views 100,000 +

Guess you like

Origin blog.csdn.net/weixin_44036154/article/details/104942721