Want to do a basic example of message queue implementation scenario, but online is to monitor the message, and then in the consumer, but they are just a Listener Listener to monitor the all groups, a situation in which all consumers, they are the specific implementation scenario, I’m not very understand person, the following is my personal thought of the scene, if there is any omissions also give advice or comments please!!!!!!

Imagine 1

There is a scene where I subscribe to a person’s news feed, wait for him to release the news feed, can notify me in many ways, he released the news feed to ask me to see, notification method (email notification, SMS notification), release the news feed initial process is he released the news feed “email notification” SMS notification This is not normal. I have to go through so many notification processes when I publish a dynamic. In case a process gets stuck, I have to wait a few minutes before I return to the dynamic publish success

Make a message queue to optimize the above example

The figure above is optimized so that he can publish the feed without waiting for all the notifications to finish before returning to show that the feed has been successfully published, hand over the notification to a third party, and notify everyone who needs to be notified.

Assumption 2

Publish/subscribe scenarios, subscriptions with notifications, notifications of what? Notice me why why to let you see, like Zhang SAN and Li Si subscription to the old wang downstairs to repair the water faucet, then Zhang SAN and Li Si to ask Lao Wang, what notice (belong to Zhang SAN and Li Si’s personal privilege), then notice what way to notice (Zhang SAN and Li Si)? Little secret!! , Zhang SAN is Lao Wang’s good buddy), Lao Wang said QQ notice you, hey hey hey!!

subsequent

From the above scene that Zhang SAN is a good friend of Lao Wang, and Li Si has less privilege

  • Zhang SANQQ notice, SMS notice, telephone notice.
  • Li siQQ notification.

To see from the picture, a small script written Lao wang is the consumer, by the news of his operation of pharaoh inform zhang SAN and li si, but the privilege of zhang SAN and li si is not the same, we just have to let the foot was terminated without corresponding privileges messages, such as Lao wang issued a message to the queue and carry (corresponding with the privilege of known zhang SAN and li si), the content is in the afternoon to lee aunt hoses Head… This content to three groups to get (Lao Wang booked in advance of the service), the next to see a small script (consumers), the next is to send a message to inform them two, Lao Wang to action!!

  • QQ notification (two small script) : 1 the script didn’t notice, message 2 by scripts to get the message of zhang SAN and li si and corresponding with the privileges and inform the privileged, send, zhang SAN and li si are privileged behind, send QQ messages to them, for the small script to service sends a message that the message has been sent (tag has been sent, manual ack).

  • SMS notification (two small scripts) : script 2 did not pay attention, the message was script 1 to get the message in the three and Four and the corresponding privilege and inform the privileged people, three notice, found that four has no privilege, will not send SMS to four!! , followed by a message to the small script to the service saying that the message has been sent (indicating that it has been sent, manual ack).

  • Telephone notice (two small scripts) : script 2 did not pay attention to, the message was script 1 to get the message in the three and Four and the corresponding privilege and inform the privilege of the people, three notice, found that four has no privilege, will not call four!! , followed by a message to the small script to the service saying that the message has been sent (indicating that it has been sent, manual ack).

summary

The above content, is similar to the publish/subscribe, I issued a content, subscribe to my people get corresponding notice, what’s notice, depends on the people subscribe to personal privileges, it is good for example: zhang opens the email notification in the background, but there is no open SMS, when processing messages according to subscribe to the personal privilege to inform the news if we need to implement a notice!!!!!! This is only an email notification to Zhang SAN!!

conclusion

The above requirement cases, is there a variety of types of notification, the order of notification is not orderly notification, it is possible to notify 2 to the user first, in the notification 1 in the notification to the user, the implementation of the scene or according to your business to achieve, the above cases can be regarded as an idea!!

Code cloud address: Java implementation of Redis Stream data structure message queue Demo

A daily soup


Please do not pass on bad words to others. You may not care, but others will remember. Please do not pass on bad words to others. You may not care, but others will remember.