Redis middleware (subscription)

Source: Internet
Author: User

What is message-oriented middleware? The publishing and subscription of point-to-point message-oriented middleware is asynchronous communication.

Case: Use redis for publishing and subscription

Redis publish and subscribe

 

Redis pub/sub is a message communication mode: the sender (pub) sends messages, and the subscriber (sub) receives messages.

Redis clients can subscribe to any number of channels.

Shows the relationship between channel channel1 and the three clients that subscribe to the channel-Client2, client5, and Client1:

 

When a new message is sent to channel channel1 through the publish command, the message is sent to the three clients that subscribe to it:

 

Client2 publishes topics channel1 client5 and Client1 subscribe to topics

Client2 publishes a topic, and other topics are subscribed to and consumed.

 

How does one implement the publish/subscribe function?

Connect two redis clients,

First, create a channel:

Enable another client to send values to this channel

Observe the first client:

Publish a subscription

Producer and consumer

 

Redis middleware (subscription)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.