A kind of real-time supplying system of display data and method based on non-obstruction queue
Technical field
The present invention relates to the data-pushing technology in data communication, specifically a kind of displaying based on non-obstruction queue
The real-time supplying system of data and method.
Background technique
Currently, in application server end and client data push technology, push technology for long-polling and
Two kinds of data-pushing implementations of websocket are there are relatively big difference, and long-polling shares based on memory, polling request
Data in audit memory;Websocket is based on monitoring in real time, establishes after monitoring, after data variation, real-time calling interface is pushed away
It send.Current push technology is supported the data of two ways and disunity, is often required to realize two sets of backstages, moreover,
The push mode of websocket, data-pushing is excessively frequent, can server-side network plug is dead, influences whether Client browse
The normal operation of device.
Summary of the invention
The present invention is directed to the demand and shortcoming of current technology development, provides a kind of displaying number based on non-obstruction queue
Supplying system and method when factually.
A kind of real-time supplying system of display data and method based on non-obstruction queue of the present invention, solves above-mentioned technology
Problem is the technical solution adopted is as follows: a kind of real-time supplying system of display data based on non-obstruction queue, system tray
Structure specifically includes that WEB component, data routing, public monitor, session monitor, data pool and six skills of cache manager
Art component;Wherein, WEB component is responsible for communicating with client browser, and WEB component receives the http request of browser, data road
By receiving the request of WEB component, and judge request type, forwards requests to corresponding monitor;Public monitor is responsible for prison
Readjustment global data is listened, receives the request that data routing forwarding comes, and when data change, respond request;The meeting
Words monitor is responsible for monitoring readjustment detailed data, receives the request that data routing forwarding comes;The data pool is responsible for generating number
According to index, cache manager is called to carry out data storage;The cache manager is responsible for receiving data, executes serializing, and root
It is stored according to caching rank, the data after unserializing is provided according to data directory.
Preferably, WEB component receives the http request of browser, gets parms from http request, and calls other skills
Art component;After other technologies component returns to request content, return request content is assembled according to format and sends back to browser.
Preferably, the data routing is responsible for receiving the request of WEB component, stores the request routing table of monitor, and root
Request type is judged according to the parameter of request, and corresponding monitor is forwarded to according to request routing table.
Preferably, when global data has any variation, public monitor starting is triggered, built-in non-obstruction monitors queue;
When data change in data pool, data directory actively can be put into non-obstruction and monitor queue by data pool.
Preferably, the corresponding prison when request needs the detailed data monitored to change, in meeting triggering session monitor
Listen thread;Receive the request that data routing forwarding comes, individually establish thread, creates non-obstruction and monitor queue, monitored;?
When data in data pool change, data directory is actively put into non-obstruction and monitors queue by data pool, and session monitor is rung
It should request.
Preferably, the data pool is responsible for the calculated result of other assemblies in reception system, establishes the data of calculated result
Index, and be distributed in corresponding monitor;After calculated result serializing, data storage is carried out by cache manager;Work as prison
When device being listened to be triggered, holds data directory and obtain data from data pool, data pool is according to data directory, from cache manager
Obtain data respond request.
A kind of real-time method for pushing of display data based on non-obstruction queue monitors common data using non-obstruction queue
It generates, and according to the session information of request, the distinguishing real-time active push of calculation result data is shown to browser;
Detailed process includes the following steps:
1) client browser initiates request, the real-time calculation result data of request;
2) WEB component receives request, and necessary parameter is obtained from request, after assembling, calls data routing;It carries out complete
Office monitors or personalized monitoring.
Preferably, global monitor includes the following steps:
Branch line process a1: data route the content according to request monitoring, judge this request according to request routing table, need road
By to public monitor;
Branch line process a2: after public monitor receives request, request is added in readjustment list;When data pool sends number
After indexing monitor, monitor calls data pool, obtains data;
Branch line process a3: data pool calls cache manager to obtain data according to incoming index information;
Branch line process a4: cache manager after unserializing data, returns to public monitoring according to incoming index information
Device;
Branch line process a5: the data obtained from cache manager are returned to WEB component by public monitor;
After branch line process a6:WEB component receives data, data are assembled according to the format of agreement and return to browser.
Preferably, personalized monitor includes the following steps:
Branch line process b1: data route the content according to request monitoring, judge that this request needs road according to request routing table
By to session monitor;
Branch line process b2: after session monitor receives request, according to the session id carried in request, corresponding non-resistance is obtained
Plug monitors queue;After data pool sends data directory to monitor, monitor calls data pool, obtains data.
Branch line process b3: data pool calls cache manager to obtain data according to incoming data directory;
Branch line process b4: cache manager after unserializing data, returns to session monitoring according to incoming index information
Device;
Branch line process b5: the data obtained from cache manager are returned to WEB component by session monitor;
After branch line process b6:WEB component receives data, data are assembled according to the format of agreement and return to browser.
Preferably, in branch line process b2, if obtaining less than for new session, the non-obstruction of creation monitors queue, request
New creation is added to monitor in the readjustment list of queue;If can get, request is directly added to corresponding monitoring queue
It adjusts back in list.
A kind of real-time supplying system of display data and method and prior art phase based on non-obstruction queue of the present invention
Than having the beneficial effect that the present invention for calculating in development process in real time, shows that application is (clear from server end to client
Look at device) the real-time calculation result data of push conversation rank;It can effectively solve the problem that the technical problems existing in the prior art, it can
It avoids overlapping development, improve development efficiency;It can accomplish personalized push, the effective use for improving memory in session-level
Rate improves the real-time of data-pushing, and then improves resource utilization.
Figure of description
Attached drawing 1 is the operation schematic diagram of the real-time supplying system of display data based on non-obstruction queue.
Specific embodiment
To make the objectives, technical solutions, and advantages of the present invention clearer, below in conjunction with specific embodiment, to this hair
A kind of bright real-time supplying system of display data and method further description based on non-obstruction queue.
In order to solve under real-time computing technique frame, how efficiently, accurately, in session-level realize that data push in real time
The problem of to client, the invention discloses a kind of real-time supplying systems of display data and method based on non-obstruction queue, change
It is pushed to the mode of browser into legacy data, the mode of shared drive is read by poll, is changed to monitor team using non-obstruction
Column are realized as core technology.The present invention monitors the generation of common data using non-obstruction queue, in the feelings of secure session
Under condition, and according to the session information of request, the distinguishing real-time active push of calculation result data is shown to browser.
Embodiment:
A kind of real-time supplying system of display data based on non-obstruction queue, system architecture described in the present embodiment are mainly wrapped
It includes: WEB component, data routing, public monitor, session monitor, data pool and the big component of cache manager technology six;Its
In, the WEB component is responsible for communicating with client browser, and WEB component receives the http request of browser, and data routing receives
The request of WEB component, and judge request type, forward requests to corresponding monitor;The public monitor is responsible for monitoring
Global data is adjusted back, receives the request that data routing forwarding comes, and when data change, respond request;The session
Monitor is responsible for monitoring readjustment detailed data, receives the request that data routing forwarding comes;The data pool is responsible for generating data
Index calls cache manager to carry out data storage;The cache manager is responsible for receiving data, executes serializing, and according to
Caching rank is stored, and the data after unserializing are provided according to data directory.
The WEB component is responsible for communicating with client browser.WEB component receives the http request of browser, from http
It gets parms in request, and calls other technologies component;After other technologies component returns to request content, assembles and return according to format
Request content sends back to browser.Here, agreement format when format is each project implementation, each project are different;Usually all
Using json data format.
The data routing is responsible for receiving the request of WEB component, stores the request routing table of monitor, and according to request
Parameter judges request type, is forwarded to corresponding monitor according to request routing table.It is opened by public monitor and session monitor
When dynamic, the information that Active Registration can be monitored is into request routing table.
The public monitor is responsible for the monitoring readjustment of global data;Public affairs can be all triggered when global data has any variation
Monitor altogether;When starting, built-in non-obstruction monitors queue, and when data change in data pool, data pool can be actively data
Index is put into non-obstruction and monitors queue.Receive the request that data routing forwarding comes, and when data change, response is asked
It asks.It is 10 seconds that public monitor requests the longest retention time every time, more than the request of this time, can actively be disconnected, to keep
The performance of monitor.The global data includes: the data of listening components generating state variation, the highest total amount of abstraction hierarchy
According to, need the detailed data broadcasted, global data is by data pool management.
The session monitor is the monitor according to conversation establishing, is responsible for the monitoring readjustment of detailed data;When request needs
It, all can correspondence listening thread in triggering session monitor when the detailed data to be monitored changes;Receive data routing to turn
Thread is individually established in the request sent, is created non-obstruction and is monitored queue, monitored, and the data in data pool occur
When variation, data directory actively can be put into non-obstruction and monitor queue by data pool, and session monitor at this time can respond request.Session
It is 10 seconds that monitor requests the longest retention time every time, more than the request of this time, can actively be disconnected, to keep monitor
Performance.The detailed data refers to that in addition to global data, the data in other data pools, detailed data is by data pool management.
The data pool is responsible for the calculated result of other assemblies in reception system, establishes the data directory of calculated result, and
It is distributed in corresponding monitor, after calculated result serializing, data storage is carried out by cache manager.When monitor is touched
When hair, holds data directory and obtain data from data pool, data pool obtains data according to data directory from cache manager
Respond request.
The cache manager is responsible for receiving data, serializing is executed, and stored according to caching rank, according to data
Index provides the data after unserializing;Caching rank divides three-level: local file storage, local memory storage, cache
Storage.Data referencing and incoming index information after cache manager storage establish key-value pair, save in memory.Data pool
Holding index information calls cache manager to obtain the data after unserializing.
Using the real-time supplying system of display data described in the present embodiment, a kind of real-time method for pushing of display data is realized, it should
Method specific implementation process includes the following steps:
1) client browser initiates request, the real-time calculation result data of request;Here request is long-
What polling or websocket technology was realized, long-polling realizes the http calling referred to through rest style, passes through
The mode of poll is continual to obtain real-time calculation result data;Websocket realization refers to by establishing browser and service
The socket connection at device end, is connected, server active push data to browser end by socket;
2) WEB component receives request, and necessary parameter is obtained from request, after assembling, calls data routing;Such as attached drawing
Shown in 1: being divided into global monitor and monitor two kinds of monitoring types with personalized.
Global monitor mainly comprises the following processes: branch line process a1, branch line process a2, branch line process a3, branch line mistake
Journey a4, branch line process a5 and branch line process a6;It is as shown in Fig. 1:
Branch line process a1: data route the content according to request monitoring, judge this request according to request routing table, need road
By to public monitor.Active note of the data source of request routing table when public monitor and session monitor start
Volume;
Branch line process a2: after public monitor receives request, request is added in readjustment list;When data pool sends number
After indexing monitor, monitor calls data pool, obtains data;
Branch line process a3: data pool calls cache manager to obtain data according to incoming index information;
Branch line process a4: cache manager after unserializing data, returns to public monitoring according to incoming index information
Device;
Branch line process a5: the data obtained from cache manager are returned to WEB component by public monitor;
After branch line process a6:WEB component receives data, data are assembled according to the format of agreement and return to browser.
Personalized monitor mainly comprises the following processes: branch line process b1, branch line process b2, branch line process b3, branch line
Process b4, branch line process b5 and branch line process b6;It is as shown in Fig. 1:
Branch line process b1: data route the content according to request monitoring, judge this request according to request routing table, need road
By to session monitor;
Branch line process b2: after session monitor receives request, according to the session id carried in request, corresponding non-resistance is obtained
Plug monitors queue.If obtaining less than for new session, the non-obstruction of creation monitors queue, and request is added to new creation and is monitored
In the readjustment list of queue;If can get, directly request is added in the corresponding readjustment list for monitoring queue.Work as data
After pond sends data directory to monitor, monitor calls data pool, obtains data.
Branch line process b3: data pool calls cache manager to obtain data according to incoming index information;
Branch line process b4: cache manager after unserializing data, returns to session monitoring according to incoming index information
Device;
Branch line process b5: the data obtained from cache manager are returned to WEB component by session monitor;
After branch line process b6:WEB component receives data, data are assembled according to the format of agreement and return to browser.
Above-mentioned specific embodiment is only specific case of the invention, and scope of patent protection of the invention includes but is not limited to
Above-mentioned specific embodiment, any person of an ordinary skill in the technical field that meet claims of the present invention and any
The appropriate change or replacement done to it, all shall fall within the protection scope of the present invention.