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)