1. What is Pub/sub
Pub/sub function (means Publish, Subscribe) is the publishing and subscription function. In an event-based system, Pub/sub is a widely used communication model that uses events as a basic communication mechanis
Pub/Sub publish and subscribe, pubsub publish and subscribeRelated commandsPSUBSCRIBEPUBLISHPUBSUBPUNSUBSCRIBESUBSCRIBEUNSUBSCRIBEPub/SubSUBSCRIBE, UNSUBSCRIBE and PUBLISH implement the Publish/Subscribe messaging paradigm where (citing Protocol) senders (publishers) are not programmed to send their messages to specific receivers (subscribers ). rather, published messages are characterized into channels, wi
.
Queuesender
Client sends message to queue with Queuesender
Queuebrowser
The client can queuebrowser the messages in the queue, but will not take the messages.
Queuerequestor
JMS provides the Queuerequestor class to simplify the process of sending and receiving messages. The Queuerequestor constructor has two parameters: Queuesession and Queue,queuerequestor complete the final send and receive message request by creating a temporary queue
I. Introduction of the Scene
A recent project needs to use the Publish/Subscribe information system to inform the latest real-time messages. After finding out that Redis pub/sub (information system for publish/subscribe) can meet my development needs, and the cost of learning and use is also relatively low.
Two. What is Redis pub/
The Pub/sub function is also the Publish/subscribe function, which is the Publish subscription function. In an event-based system, PUB/SUB is a widely used communication model that uses events as a basic communication mechanism to provide loosely coupled interaction patterns required by large-scale systems: subscribers
message to queue with Queuesender
Queuebrowser
The client can queuebrowser the messages in the queue, but will not take the messages.
Queuerequestor
JMS provides the Queuerequestor class to simplify the process of sending and receiving messages. The Queuerequestor constructor has two parameters: Queuesession and Queue,queuerequestor complete the final send and receive message request by creating a temporary queue.
Reliability (Reliability)
The que
I. Release and subscription mechanismsWhen a client sends a message to a subscriber via the PUBLISH command, we call the client Publisher.When a client uses the SUBSCRIBE or Psubscribe command to receive information, we call the client the Subscriber (Subscriber).To understand the relationship between a decoupled publisher (publisher) and a Subscriber (subscriber), Redis uses the channel as an intermediary for both-the publisher publishes the information directly to the channel, and the channel
I. Release and subscription mechanismsWhen a client sends a message to a subscriber via the PUBLISH command, we call the client Publisher.When a client uses the SUBSCRIBE or Psubscribe command to receive information, we call the client the Subscriber (Subscriber).To understand the relationship between a decoupled publisher (publisher) and a Subscriber (subscriber), Redis uses the channel as an intermediary for both-the publisher publishes the information directly to the channel, and the channel
1. Peer modelThe following concepts are found in the peer-to model: Message Queuing (queue), Sender (sender), receiver (receiver). Each message is sent to a specific queue, and the recipient obtains the message from the queue. The queue retains the message until they are consumed or timed out .? only one consumer per message (Consumer) (that is, once consumed, the message is no longer in the message queue)? there is no dependency on time between the sender and the receiver , that is, when the s
the first element represents the message type.Format of the push messageThe message is a multi-block response with three elements.The first element is a message type:
subscribe: Indicates that we successfully subscribed to the channel provided by the second element of the response. The third parameter represents the number of channels that we subscribe to now.
unsubscribe: Indicates that we successfully unsubscribe to the channel provided by the second element of the response. The
http://blog.csdn.net/canot/article/details/52040415About the individual's understanding of the pub/sub mechanism provided by Redis in the previous blog, it also mentions the idea of how to avoid one of the biggest flaws in Redis's pub/sub-The Persistence of messages (http://blog.csdn.net/canot/ article/details/51975566
Fully quoted from: https://my.oschina.net/alexgaoyh/blog/338890 interpretation is very good.
1. Peer modelThe following concepts are available in the peer-to model:
Message Queuing (queue),
Sender (Sender),
Receiver (receiver).
Each message is sent to a specific queue, and the recipient obtains the message from the queue. The queue retains the message until they are consumed or timed out .? only one consumer per message (Consumer) (that is, once consumed, the
The understanding of individual pub/sub mechanisms provided by Redis is covered in the previous blog, as well as the idea of how to avoid one of the biggest flaws in Redis pub/sub-The persistence of messages (http://blog.csdn.net/canot/ article/details/51975566). This article is mainly about the code implementation of
Here, using Nodejs's Redis module description, specifically visible Https://www.npmjs.com/package/redis, first come through a simple example of the pub/sub in Redis how to implement it.var express = require (' Express '); var router = Express. Router (); var Redis = require ("Redis"); /* GET home page. */router.get ('/', function (req, res, next) {var client1 = redis.createclient (); var client2 = redis.c
JavaScript-Implemented Publish/subscribe (PUB/SUB) modeTime 2016-05-02 18:47:58 giantming ' s blogOriginal http://giantming.net/javascriptshi-xian-de-fa-bu-ding-yue-pub-sub-mo-shi/Topic JavaScript Viewer ModeSome time ago I looked at the Publish subscriber mode (also known as the Observer mode), today Some front-end MV
) throwsException{ initialcontext ctx=newinitialcontext (); // Get Queueconnectionfactory Objects queueconnectionfactoryfactory= (queueconnectionfactory) ctx.lookup (" Queueconnectionfactory "); //create queueconnection queueconnectionconnection=factory.createqueueconnection (); //Create session NBSP;NBSP;NBSP;NBSP;//ARG1: Related to a thing, true means last commit, false means auto-commit NBSP;NBSP;NBSP;NBSP;//ARG2: Indicates that the message sends a confirmation notification to the middl
Redis Publish SubscriptionsA Redis Publish Subscription (PUB/SUB) is a message communication pattern: the Sender (pub) sends a message and the Subscriber (sub) receives the message.Redis clients can subscribe to any number of channels.Shows the relationship between channel Channel1 and the three client--client2, CLIENT
Demand:
In order to accurately monitor the internal state of each server, without affecting the existing business logic, a simple centralized monitoring system for the server needs to be deployed quickly. After consideration, you can use the Redis pub/sub function to implement a monitoring system is very good and appropriate.
Of course, we can also pass this to do batch management.
Redis Programming Practice "Pub/sub"
Blog Categories:Redis
Redis may have started to promote and test water in many enterprises, this article also according to individual practice, briefly describes Redis in the actual development process of use (Deployment and architecture, later), program execution Environment for Java + Jedis, For more information on how to integrate REDIS-API under Spring, introduce i
There are three things that are critical to Ajax-driven single-page applications: Time delegation, history management, and Communication mode (PUB/SUB). First of all, let's introduce what pub/sub is. We can call this thing a broadcast, which means that when you publish something, everyone else gets it. You can think a
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.