当前位置:网站首页>Consumption mode of Message Oriented Middleware

Consumption mode of Message Oriented Middleware

2022-06-10 14:32:00 morningcat2018

The consumption pattern of message oriented middleware

Push Pattern :

advantage The message can be sent to consumers as soon as possible ( stay Pull In this mode, you need to constantly pull messages , Because I don't know whether there are new messages in the message queue )
Inferiority The server does not know the consumption capacity of the consumer , Constantly sending messages may cause the consumer side buffer to overflow

ActiveMQ Use in prefetch limit Address these weaknesses

 When the number of push messages reaches perfetch limit Specified value , The consumer has not yet returned to the message oriented middleware ACK, Message oriented middleware will no longer push messages to consumers 
 If the number of messages is small ( Producers are producing messages at a slow rate ), But every message   Consumers need a long time to deal with , that prefetch limit Set to 1 More appropriate .
prefetch limit  Set to  0  It means at this time , The consumer polls the message middleware to get the message . No more Push Way , It is Pull Way . That is, consumers take the initiative to pull messages from the message middleware .

Pull Pattern :

advantage The consumer end can be pulled out according to the processing capacity
Inferiority Will increase message latency ( Consumers don't know when there is news , Can only keep pulling messages , But not too often ; Therefore, a time is usually set , Pull it every once in a while , This time is the message delay time )

Pull mode

Implementation of various message oriented middleware

Long polling

RocketMQ Long polling

Kafka Long polling
 Insert picture description here


Java Design patterns in source code

原网站

版权声明
本文为[morningcat2018]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/161/202206101413474964.html