CN117914943A - Data subscription and pushing method, device, equipment and medium - Google Patents

Data subscription and pushing method, device, equipment and medium Download PDF

Info

Publication number
CN117914943A
CN117914943A CN202410316299.5A CN202410316299A CN117914943A CN 117914943 A CN117914943 A CN 117914943A CN 202410316299 A CN202410316299 A CN 202410316299A CN 117914943 A CN117914943 A CN 117914943A
Authority
CN
China
Prior art keywords
data
event
target
service
processed
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN202410316299.5A
Other languages
Chinese (zh)
Other versions
CN117914943B (en
Inventor
袁晓钉
袁杰
何磊
洪磊明
马银银
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shanghai Huarui Software Co ltd
Shenzhen Huarui Distributed Technology Co ltd
Original Assignee
Shanghai Huarui Software Co ltd
Shenzhen Huarui Distributed Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Shanghai Huarui Software Co ltd, Shenzhen Huarui Distributed Technology Co ltd filed Critical Shanghai Huarui Software Co ltd
Priority to CN202410316299.5A priority Critical patent/CN117914943B/en
Publication of CN117914943A publication Critical patent/CN117914943A/en
Application granted granted Critical
Publication of CN117914943B publication Critical patent/CN117914943B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Landscapes

  • Information Transfer Between Computers (AREA)
  • Computer And Data Communications (AREA)

Abstract

The invention relates to the technical field of big data, and provides a data subscription and pushing method, device, equipment and medium, which can distribute service data to a lock-free queue by utilizing a first thread according to the service attribute of the service data sent by a service system, and then read the data from the lock-free queue by utilizing a single thread, and decouple the distribution and the reading process of the data, so that the reading operation does not need to wait for the completion of the distribution, thereby reducing the time delay; and the read data codes are stored in a global message cache table, so that the data corresponding to the event to be processed can be quickly read from the global message cache table by using an event driver as target data, and then the target data is pushed to a business system, thereby improving the performance of data subscription and pushing services.

Description

Data subscription and pushing method, device, equipment and medium
Technical Field
The present invention relates to the field of big data technologies, and in particular, to a method, an apparatus, a device, and a medium for subscribing and pushing data.
Background
The gateway in the data service system is a key component, and serves as a middle layer between the data service system and an external system or application, and is used for providing services such as route management, load balancing, authentication, protocol conversion, API (Application Programming Interface ) management and the like. In some special-needs scenarios, the data service system is deployed in an intranet, and does not need to face a complex internet environment, so when the gateway user does not need to consider the security problem any more, the core appeal to the gateway will become extremely performance, such as the time for data to penetrate the gateway, the data throughput capability of the gateway, and so on.
However, in the current data subscription and push scenarios, the delay and the data throughput of the data penetrating the gateway are still to be improved.
Disclosure of Invention
In view of the foregoing, it is necessary to provide a method, an apparatus, a device and a medium for subscribing and pushing data, which aim to solve the problems of high delay of data penetrating a gateway and low data throughput during subscribing and pushing data.
A data subscription and push method, applied to a data service gateway, the data subscription and push method comprising:
When receiving service data sent by a service system through a message middleware, acquiring service attributes of the service data, and distributing the service data to a lock-free queue by utilizing a first thread according to the service attributes;
Reading data from the lock-free queue by using a second thread, and encoding the read data according to a reading sequence to obtain data to be stored;
storing the data to be stored into a global message cache table;
when receiving a subscription request initiated by a target client, encapsulating the subscription request into an event as an event to be processed, and issuing the event to be processed to a target event driver corresponding to the target client;
reading data corresponding to the event to be processed from the global message cache table by using the target event driver as target data;
and pushing the target data to the service system.
According to a preferred embodiment of the present invention, before the delivering the event to be processed to the target event driver corresponding to the target client, the method further includes:
When the data service gateway is detected to be started, acquiring the number of the pre-configured event drivers;
starting at least one event driver packaged in advance according to the number of the event drivers; each event driver is obtained by packaging based on a lock-free queue technology and a single-thread technology;
binding the client connection corresponding to each client to the corresponding event driver according to the configured load balancing algorithm;
for the bound client connection, all events generated by the client connection are processed by an event driver bound with the client connection;
Wherein the load balancing algorithm is configured according to an address or a polling mode.
According to a preferred embodiment of the present invention, the reading, by the target event driver, data corresponding to the event to be processed from the global message cache table as target data includes:
Acquiring the code of the event to be processed as a code to be matched;
matching is carried out in the global message cache table by utilizing the codes to be matched;
And when the codes which are the same as the codes to be matched are matched in the global message cache table, reading data corresponding to the matched codes from the global message cache table as the target data.
According to a preferred embodiment of the invention, the method further comprises:
when the codes which are the same as the codes to be matched are matched in the global message cache table, adding 1 to the codes of the events to be processed to obtain new events;
and issuing the new event to the target event driver.
According to a preferred embodiment of the invention, the method further comprises:
and when the codes which are the same as the codes to be matched are not matched in the global message cache table, the event to be processed is re-issued to the target event driver, and the next round of matching is waited.
According to a preferred embodiment of the invention, the method further comprises:
When the connection disconnection corresponding to the target client is detected, a disconnection event is generated;
And issuing the disconnection event to the target event driver, and removing the session corresponding to the target client from the target event driver.
According to a preferred embodiment of the present invention, the global message cache table is an ordered linked list based on a binary search configuration.
A data subscription and push device operating at a data service gateway, the data subscription and push device comprising:
The distributing unit is used for acquiring service attributes of the service data when the service data sent by the service system through the message middleware is received, and distributing the service data to a lock-free queue by utilizing a first thread according to the service attributes;
the encoding unit is used for reading data from the lock-free queue by using a second thread, and encoding the read data according to a reading sequence to obtain data to be stored;
The storage unit is used for storing the data to be stored into a global message cache table;
The issuing unit is used for packaging the subscription request into an event to be processed as an event to be processed when receiving the subscription request initiated by the target client, and issuing the event to be processed to a target event driver corresponding to the target client;
A reading unit, configured to read, by using the target event driver, data corresponding to the event to be processed from the global message cache table as target data;
And the pushing unit is used for pushing the target data to the service system.
A computer device, the computer device comprising:
A memory storing at least one instruction; and
And the processor executes the instructions stored in the memory to realize the data subscription and pushing method.
A computer-readable storage medium having stored therein at least one instruction for execution by a processor in a computer device to implement the data subscription and push method.
According to the technical scheme, the service data can be distributed to the lock-free queue by the first thread according to the service attribute of the service data sent by the service system, and then the data is read from the lock-free queue by the single thread, so that the data distribution and the reading process are decoupled, the reading operation does not need to wait for the completion of the distribution, and the time delay is further reduced; and the read data codes are stored in a global message cache table, so that the data corresponding to the event to be processed can be quickly read from the global message cache table by using an event driver as target data, and then the target data is pushed to a business system, thereby improving the performance of data subscription and pushing services.
Drawings
FIG. 1 is a flow chart of a preferred embodiment of the data subscription and push method of the present invention.
FIG. 2 is a functional block diagram of a preferred embodiment of the data subscribing and pushing device of the present invention.
Fig. 3 is a schematic structural diagram of a computer device according to a preferred embodiment of the present invention for implementing the data subscription and push method.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, the present invention will be described in detail with reference to the accompanying drawings and specific embodiments.
FIG. 1 is a flow chart of a preferred embodiment of the data subscription and push method of the present invention. The order of the steps in the flowchart may be changed and some steps may be omitted according to various needs.
The data subscription and pushing method is applied to one or more computer devices, wherein the computer device is a device capable of automatically performing numerical calculation and/or information processing according to preset or stored instructions, and the hardware of the computer device comprises, but is not limited to, a microprocessor, an Application SPECIFIC INTEGRATED Circuit (ASIC), a Programmable gate array (Field-Programmable GATE ARRAY, FPGA), a digital Processor (DIGITAL SIGNAL Processor, DSP), an embedded device and the like.
The computer device may be any electronic product that can interact with a user in a human-computer manner, such as a personal computer, a tablet computer, a smart phone, a personal digital assistant (personal DIGITAL ASSISTANT, PDA), a game console, an interactive internet protocol television (Internet Protocol Television, IPTV), a smart wearable device, etc.
The computer device may also include a network device and/or a user device. Wherein the network device includes, but is not limited to, a single network server, a server group composed of a plurality of network servers, or a Cloud based Cloud Computing (Cloud Computing) composed of a large number of hosts or network servers.
The server may be an independent server, or may be a cloud server that provides cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, content delivery networks (Content Delivery Network, CDN), and basic cloud computing services such as big data and artificial intelligence platforms.
Wherein artificial intelligence (ARTIFICIAL INTELLIGENCE, AI) is the theory, method, technique, and application system that uses a digital computer or a digital computer-controlled machine to simulate, extend, and expand human intelligence, sense the environment, acquire knowledge, and use knowledge to obtain optimal results.
Artificial intelligence infrastructure technologies generally include technologies such as sensors, dedicated artificial intelligence chips, cloud computing, distributed storage, big data processing technologies, operation/interaction systems, mechatronics, and the like. The artificial intelligence software technology mainly comprises a computer vision technology, a robot technology, a biological recognition technology, a voice processing technology, a natural language processing technology, machine learning/deep learning and other directions.
The network in which the computer device is located includes, but is not limited to, the internet, a wide area network, a metropolitan area network, a local area network, a virtual private network (Virtual Private Network, VPN), and the like.
The embodiment is applied to a data service gateway, and comprises the following steps:
S10, when service data sent by a service system through a message middleware are received, service attributes of the service data are obtained, and the service data are distributed to a lock-free queue by utilizing a first thread according to the service attributes.
In this embodiment, the service attribute may include, but is not limited to, one or more of the following combinations: stock type exchange data, option type exchange data, two-melt type exchange data, etc.
In this embodiment, the lock-free queue supports simultaneous processing and access to a large amount of data, and the lock-free queue can ensure that the data is as secure as if there were a lock without additional locks.
S11, reading data from the lock-free queue by using a second thread, and encoding the read data according to a reading sequence to obtain data to be stored.
In this embodiment, a single thread is started to continuously read data from the lock-free queue, so that the original first thread continuously distributes the service data to the lock-free queue, and another second thread continuously reads data from the lock-free queue, so that the data distribution and the reading process are decoupled, the data reading operation does not need to wait for the completion of the distribution, thereby not only reducing the congestion probability, but also effectively reducing the delay.
In this embodiment, the read data is encoded according to the reading sequence, so that a unique number is added to each data, which is convenient for subsequent searching of the data, and improves the searching accuracy.
For example: the first read data may be numbered 1 and the second read data may be numbered 2, and so on, resulting in a code for each data.
And S12, storing the data to be stored into a global message cache table.
In this embodiment, the global message cache table is an ordered linked list based on binary search configuration.
By binary search, the data query efficiency can be effectively improved.
And, the global message buffer table may include a plurality of sub-tables, each sub-table may correspond to a service attribute.
For example: for the first data stored in the first sub-table, it may be encoded as A1, for the second data stored in the first sub-table, it may be encoded as A2, and so on; similarly, for the first data stored in the second sub-table, B1 may be encoded, for the second data stored in the second sub-table, B2 may be encoded, and so on.
S13, when receiving a subscription request initiated by a target client, packaging the subscription request into an event as a to-be-processed event, and issuing the to-be-processed event to a target event driver corresponding to the target client.
In this embodiment, the event may include, but is not limited to: network events for connection establishment and disconnection, session messages for clients, internal real-time instructions, etc.
In this embodiment, before the delivering the event to be processed to the target event driver corresponding to the target client, the method further includes:
When the data service gateway is detected to be started, acquiring the number of the pre-configured event drivers;
starting at least one event driver packaged in advance according to the number of the event drivers; each event driver is obtained by packaging based on a lock-free queue technology and a single-thread technology;
binding the client connection corresponding to each client to the corresponding event driver according to the configured load balancing algorithm;
for the bound client connection, all events generated by the client connection are processed by an event driver bound with the client connection;
Wherein the load balancing algorithm is configured according to an address or a polling mode.
For example: according to the load balancing algorithm, client connections with the same IP (Internet Protocol ) address or MAC (MEDIA ACCESS control address) address may be bound to the same event driver, or when three event drivers are started, the client connections are sequentially bound to each event driver in a round robin fashion, specifically, a first client connection is bound to the first event driver, a second client connection is bound to the second event driver, a third client connection is bound to the third event driver, the first round robin is completed, when there is a fourth client connection, the fourth client connection is again polled from the first event driver, the fifth client connection is bound to the second event driver, the sixth client connection is bound to the third event driver, and so on, until all client connections are bound.
In addition, because each event driver is obtained by packaging based on the lock-free queue technology and the single-thread technology, the receiving process and the processing process of each event driver for the event are decoupled, and the delay is reduced.
S14, the target event driver is utilized to read data corresponding to the event to be processed from the global message cache table as target data.
In this embodiment, the reading, by the target event driver, data corresponding to the event to be processed from the global message cache table as target data includes:
Acquiring the code of the event to be processed as a code to be matched;
matching is carried out in the global message cache table by utilizing the codes to be matched;
And when the codes which are the same as the codes to be matched are matched in the global message cache table, reading data corresponding to the matched codes from the global message cache table as the target data.
According to the embodiment, the needed data can be quickly read from the global message cache table based on the codes, and the global message cache table is a binary search linked list, so that the query efficiency is higher, and the accuracy of the queried data is ensured due to the uniqueness of the codes.
In this embodiment, the method further includes:
when the codes which are the same as the codes to be matched are matched in the global message cache table, adding 1 to the codes of the events to be processed to obtain new events;
and issuing the new event to the target event driver.
Through the above embodiment, when a code is successfully matched, a new subscription event is constructed and delivered to the current event driver to continue to start the next matching event.
In this embodiment, the method further includes:
and when the codes which are the same as the codes to be matched are not matched in the global message cache table, the event to be processed is re-issued to the target event driver, and the next round of matching is waited.
Through the above embodiment, when the matching is unsuccessful, it is indicated that the data corresponding to the code has not arrived yet, and at this time, the current subscription event is redelivered to the current event driver to wait for the next round of processing.
In this embodiment, the method further includes:
When the connection disconnection corresponding to the target client is detected, a disconnection event is generated;
And issuing the disconnection event to the target event driver, and removing the session corresponding to the target client from the target event driver.
The session is an object obtained by packaging identity information, a user name, a password and the like of a service layer and a behavior record.
And the sessions are in a one-to-one correspondence with connections, i.e. each session is associated with an underlying client connection, such as a TCP (Transmission Control Protocol ) connection.
By the above embodiment, after the session corresponding to the target client is removed from the target event driver, the subscription event associated with the subsequent session will not find the session carrier and be regarded as invalid, and will not reenter the event driver.
In this embodiment, through the cyclic reciprocation of the event driver, subscription and pushing of data can be achieved.
And S15, pushing the target data to the service system.
In this embodiment, after the target data is pushed to the service system, a response to the subscription request initiated by the target client may be completed once.
In this embodiment, the process of storing data from the service system to the global message cache table is equivalent to completing the distribution and storage of data in the data processing channels of the logic level, so that the data storage is not required to wait for the distribution to be completed based on the lock-free queue and the single thread, i.e., the upstream can continuously distribute the data to the lock-free queue by using the first thread, and the downstream can continuously read the data from the lock-free queue by using the second thread for storage (wherein each service attribute corresponds to one data processing channel, i.e., the number of the second threads is equal to the type number of the service attributes), so that the congestion phenomenon of the data can be effectively reduced, and the processing efficiency is improved; meanwhile, by combining an event driver based on a lock-free queue and single-thread configuration, the receiving and processing processes of the event do not need to wait, namely, the upstream can continuously receive the event to the lock-free queue by one thread, and the downstream can continuously read the event from the lock-free queue by another thread for processing, so that the congestion phenomenon of the event can be effectively reduced, and the event processing efficiency is improved. Thus, the data can penetrate the gateway with extremely low time delay, and the gateway also has high-performance data subscription and push services.
According to the technical scheme, the service data can be distributed to the lock-free queue by the first thread according to the service attribute of the service data sent by the service system, and then the data is read from the lock-free queue by the single thread, so that the data distribution and the reading process are decoupled, the reading operation does not need to wait for the completion of the distribution, and the time delay is further reduced; and the read data codes are stored in a global message cache table, so that the data corresponding to the event to be processed can be quickly read from the global message cache table by using an event driver as target data, and then the target data is pushed to a business system, thereby improving the performance of data subscription and pushing services.
Fig. 2 is a functional block diagram of a data subscription and pushing device according to a preferred embodiment of the present invention. The data subscribing and pushing device 11 includes a distributing unit 110, an encoding unit 111, a storing unit 112, a delivering unit 113, a reading unit 114, and a pushing unit 115. The module/unit referred to in the present invention refers to a series of computer program segments, which are stored in a memory, capable of being executed by a processor and of performing a fixed function. In the present embodiment, the functions of the respective modules/units will be described in detail in the following embodiments.
In this embodiment, the data subscribing and pushing device 11 operates in a data service gateway, and includes:
The distributing unit 110 is configured to, when receiving service data sent by a service system through a message middleware, obtain a service attribute of the service data, and distribute the service data to a lock-free queue by using a first thread according to the service attribute;
The encoding unit 111 is configured to read data from the lock-free queue by using a second thread, and encode the read data according to a reading sequence to obtain data to be stored;
The storage unit 112 is configured to store the data to be stored in a global message cache table;
The issuing unit 113 is configured to, when receiving a subscription request initiated by a target client, encapsulate the subscription request into an event as a to-be-processed event, and issue the to-be-processed event to a target event driver corresponding to the target client;
the reading unit 114 is configured to read, by using the target event driver, data corresponding to the event to be processed from the global message cache table as target data;
the pushing unit 115 is configured to push the target data to the service system.
According to the technical scheme, the service data can be distributed to the lock-free queue by the first thread according to the service attribute of the service data sent by the service system, and then the data is read from the lock-free queue by the single thread, so that the data distribution and the reading process are decoupled, the reading operation does not need to wait for the completion of the distribution, and the time delay is further reduced; and the read data codes are stored in a global message cache table, so that the data corresponding to the event to be processed can be quickly read from the global message cache table by using an event driver as target data, and then the target data is pushed to a business system, thereby improving the performance of data subscription and pushing services.
Fig. 3 is a schematic structural diagram of a computer device according to a preferred embodiment of the present invention for implementing the data subscription and push method.
The computer device 1 may comprise a memory 12, a processor 13 and a bus, and may further comprise computer programs stored in the memory 12 and executable on the processor 13, such as data subscription and push programs.
It will be appreciated by those skilled in the art that the schematic diagram is merely an example of the computer device 1 and does not constitute a limitation of the computer device 1, the computer device 1 may be a bus type structure, a star type structure, the computer device 1 may further comprise more or less other hardware or software than illustrated, or a different arrangement of components, for example, the computer device 1 may further comprise an input-output device, a network access device, etc.
It should be noted that the computer device 1 is only used as an example, and other electronic products that may be present in the present invention or may be present in the future are also included in the scope of the present invention by way of reference.
The memory 12 includes at least one type of readable storage medium including flash memory, a removable hard disk, a multimedia card, a card memory (e.g., SD or DX memory, etc.), a magnetic memory, a magnetic disk, an optical disk, etc. The memory 12 may in some embodiments be an internal storage unit of the computer device 1, such as a removable hard disk of the computer device 1. The memory 12 may also be an external storage device of the computer device 1 in other embodiments, such as a plug-in mobile hard disk, a smart memory card (SMART MEDIA CARD, SMC), a Secure Digital (SD) card, a flash memory card (FLASH CARD) or the like, which are provided on the computer device 1. Further, the memory 12 may also include both an internal storage unit and an external storage device of the computer device 1. The memory 12 may be used not only for storing application software installed in the computer device 1 and various types of data, such as codes of data subscription and push programs, but also for temporarily storing data that has been output or is to be output.
The processor 13 may be comprised of integrated circuits in some embodiments, for example, a single packaged integrated circuit, or may be comprised of multiple integrated circuits packaged with the same or different functions, including one or more central processing units (Central Processing unit, CPU), microprocessors, digital processing chips, graphics processors, various control chips, and the like. The processor 13 is a Control Unit (Control Unit) of the computer device 1, connects the respective components of the entire computer device 1 using various interfaces and lines, and executes various functions of the computer device 1 and processes data by running or executing programs or modules (e.g., executing data subscription and push programs, etc.) stored in the memory 12, and calling up data stored in the memory 12.
The processor 13 executes the operating system of the computer device 1 and various types of applications installed. The processor 13 executes the application program to implement the steps of the various data subscription and push method embodiments described above, such as the steps shown in fig. 1.
Illustratively, the computer program may be partitioned into one or more modules/units that are stored in the memory 12 and executed by the processor 13 to complete the present invention. The one or more modules/units may be a series of computer readable instruction segments capable of performing the specified functions, which instruction segments describe the execution of the computer program in the computer device 1. For example, the computer program may be divided into a distribution unit 110, an encoding unit 111, a storage unit 112, a delivery unit 113, a reading unit 114, a pushing unit 115.
The integrated units implemented in the form of software functional modules described above may be stored in a computer readable storage medium. The software functional module is stored in a storage medium, and includes several instructions for causing a computer device (which may be a personal computer, a computer device, or a network device, etc.) or a processor (processor) to execute portions of the data subscription and push method according to the embodiments of the present invention.
The modules/units integrated in the computer device 1 may be stored in a computer readable storage medium if implemented in the form of software functional units and sold or used as separate products. Based on this understanding, the present invention may also be implemented by a computer program for instructing a relevant hardware device to implement all or part of the procedures of the above-mentioned embodiment method, where the computer program may be stored in a computer readable storage medium and the computer program may be executed by a processor to implement the steps of each of the above-mentioned method embodiments.
Wherein the computer program comprises computer program code which may be in source code form, object code form, executable file or some intermediate form etc. The computer readable medium may include: any entity or device capable of carrying the computer program code, a recording medium, a U disk, a removable hard disk, a magnetic disk, an optical disk, a computer Memory, a Read-Only Memory (ROM), a random access Memory, or the like.
Further, the computer-readable storage medium may mainly include a storage program area and a storage data area, wherein the storage program area may store an operating system, an application program required for at least one function, and the like; the storage data area may store data created from the use of blockchain nodes, and the like.
The blockchain is a novel application mode of computer technologies such as distributed data storage, point-to-point transmission, consensus mechanism, encryption algorithm and the like. The blockchain (Blockchain), essentially a de-centralized database, is a string of data blocks that are generated in association using cryptographic methods, each of which contains information from a batch of network transactions for verifying the validity (anti-counterfeit) of its information and generating the next block. The blockchain may include a blockchain underlying platform, a platform product services layer, an application services layer, and the like.
The bus may be a peripheral component interconnect standard (PERIPHERAL COMPONENT INTERCONNECT, PCI) bus, or an extended industry standard architecture (extended industry standard architecture, EISA) bus, among others. The bus may be classified as an address bus, a data bus, a control bus, etc. For ease of illustration, only one straight line is shown in fig. 3, but not only one bus or one type of bus. The bus is arranged to enable a connection communication between the memory 12 and at least one processor 13 or the like.
Although not shown, the computer device 1 may further comprise a power source (such as a battery) for powering the various components, preferably the power source may be logically connected to the at least one processor 13 via a power management means, whereby the functions of charge management, discharge management, and power consumption management are achieved by the power management means. The power supply may also include one or more of any of a direct current or alternating current power supply, recharging device, power failure detection circuit, power converter or inverter, power status indicator, etc. The computer device 1 may further include various sensors, bluetooth modules, wi-Fi modules, etc., which will not be described in detail herein.
Further, the computer device 1 may also comprise a network interface, optionally comprising a wired interface and/or a wireless interface (e.g. WI-FI interface, bluetooth interface, etc.), typically used for establishing a communication connection between the computer device 1 and other computer devices.
The computer device 1 may optionally further comprise a user interface, which may be a Display, an input unit, such as a Keyboard (Keyboard), or a standard wired interface, a wireless interface. Alternatively, in some embodiments, the display may be an LED display, a liquid crystal display, a touch-sensitive liquid crystal display, an OLED (Organic Light-Emitting Diode) touch, or the like. The display may also be referred to as a display screen or display unit, as appropriate, for displaying information processed in the computer device 1 and for displaying a visual user interface.
It should be understood that the embodiments described are for illustrative purposes only and are not limited to this configuration in the scope of the patent application.
Fig. 3 shows only a computer device 1 with components 12-13, it being understood by those skilled in the art that the structure shown in fig. 3 is not limiting of the computer device 1 and may include fewer or more components than shown, or may combine certain components, or a different arrangement of components.
In connection with fig. 1, the memory 12 in the computer device 1 stores a plurality of instructions to implement a data subscription and push method, the processor 13 being executable to implement:
When receiving service data sent by a service system through a message middleware, acquiring service attributes of the service data, and distributing the service data to a lock-free queue by utilizing a first thread according to the service attributes;
Reading data from the lock-free queue by using a second thread, and encoding the read data according to a reading sequence to obtain data to be stored;
storing the data to be stored into a global message cache table;
when receiving a subscription request initiated by a target client, encapsulating the subscription request into an event as an event to be processed, and issuing the event to be processed to a target event driver corresponding to the target client;
reading data corresponding to the event to be processed from the global message cache table by using the target event driver as target data;
and pushing the target data to the service system.
Specifically, the specific implementation method of the above instructions by the processor 13 may refer to the description of the relevant steps in the corresponding embodiment of fig. 1, which is not repeated herein.
The data in this case were obtained legally.
In the several embodiments provided in the present invention, it should be understood that the disclosed systems, devices, and methods may be implemented in other manners. For example, the above-described apparatus embodiments are merely illustrative, and for example, the division of the modules is merely a logical function division, and there may be other manners of division when actually implemented.
The invention is operational with numerous general purpose or special purpose computer system environments or configurations. For example: personal computers, server computers, hand-held or portable devices, tablet devices, multiprocessor systems, microprocessor-based systems, set top boxes, programmable consumer electronics, network PCs, minicomputers, mainframe computers, distributed computing environments that include any of the above systems or devices, and the like. The invention may be described in the general context of computer-executable instructions, such as program modules, being executed by a computer. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform particular tasks or implement particular abstract data types. The invention may also be practiced in distributed computing environments where tasks are performed by remote processing devices that are linked through a communications network. In a distributed computing environment, program modules may be located in both local and remote computer storage media including memory storage devices.
The modules described as separate components may or may not be physically separate, and components shown as modules may or may not be physical units, may be located in one place, or may be distributed over multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
In addition, each functional module in the embodiments of the present invention may be integrated in one processing unit, or each unit may exist alone physically, or two or more units may be integrated in one unit. The integrated units can be realized in a form of hardware or a form of hardware and a form of software functional modules.
It will be evident to those skilled in the art that the invention is not limited to the details of the foregoing illustrative embodiments, and that the present invention may be embodied in other specific forms without departing from the spirit or essential characteristics thereof.
The present embodiments are, therefore, to be considered in all respects as illustrative and not restrictive, the scope of the invention being indicated by the appended claims rather than by the foregoing description, and all changes which come within the meaning and range of equivalency of the claims are therefore intended to be embraced therein. Any reference signs in the claims shall not be construed as limiting the claim concerned.
Furthermore, it is evident that the word "comprising" does not exclude other elements or steps, and that the singular does not exclude a plurality. The units or means stated in the invention may also be implemented by one unit or means, either by software or hardware. The terms first, second, etc. are used to denote a name, but not any particular order.
Finally, it should be noted that the above-mentioned embodiments are merely for illustrating the technical solution of the present invention and not for limiting the same, and although the present invention has been described in detail with reference to the preferred embodiments, it should be understood by those skilled in the art that modifications and equivalents may be made to the technical solution of the present invention without departing from the spirit and scope of the technical solution of the present invention.

Claims (10)

1. The data subscription and pushing method is characterized by being applied to a data service gateway, and comprises the following steps:
When receiving service data sent by a service system through a message middleware, acquiring service attributes of the service data, and distributing the service data to a lock-free queue by utilizing a first thread according to the service attributes;
Reading data from the lock-free queue by using a second thread, and encoding the read data according to a reading sequence to obtain data to be stored;
storing the data to be stored into a global message cache table;
when receiving a subscription request initiated by a target client, encapsulating the subscription request into an event as an event to be processed, and issuing the event to be processed to a target event driver corresponding to the target client;
reading data corresponding to the event to be processed from the global message cache table by using the target event driver as target data;
and pushing the target data to the service system.
2. The method of subscribing and pushing data according to claim 1, wherein before the delivering the event to be processed to a target event driver corresponding to the target client, the method further comprises:
When the data service gateway is detected to be started, acquiring the number of the pre-configured event drivers;
starting at least one event driver packaged in advance according to the number of the event drivers; each event driver is obtained by packaging based on a lock-free queue technology and a single-thread technology;
binding the client connection corresponding to each client to the corresponding event driver according to the configured load balancing algorithm;
for the bound client connection, all events generated by the client connection are processed by an event driver bound with the client connection;
Wherein the load balancing algorithm is configured according to an address or a polling mode.
3. The method of subscribing and pushing data according to claim 1, wherein the reading, by the target event driver, data corresponding to the event to be processed from the global message cache table as target data comprises:
Acquiring the code of the event to be processed as a code to be matched;
matching is carried out in the global message cache table by utilizing the codes to be matched;
And when the codes which are the same as the codes to be matched are matched in the global message cache table, reading data corresponding to the matched codes from the global message cache table as the target data.
4. The data subscription and push method of claim 3, wherein the method further comprises:
when the codes which are the same as the codes to be matched are matched in the global message cache table, adding 1 to the codes of the events to be processed to obtain new events;
and issuing the new event to the target event driver.
5. The data subscription and push method of claim 3, wherein the method further comprises:
and when the codes which are the same as the codes to be matched are not matched in the global message cache table, the event to be processed is re-issued to the target event driver, and the next round of matching is waited.
6. The data subscription and push method of claim 1, wherein the method further comprises:
When the connection disconnection corresponding to the target client is detected, a disconnection event is generated;
And issuing the disconnection event to the target event driver, and removing the session corresponding to the target client from the target event driver.
7. The data subscription and push method of claim 1 wherein the global message cache table is an ordered linked list based on a binary search configuration.
8. A data subscription and push device, operable in a data service gateway, the data subscription and push device comprising:
The distributing unit is used for acquiring service attributes of the service data when the service data sent by the service system through the message middleware is received, and distributing the service data to a lock-free queue by utilizing a first thread according to the service attributes;
the encoding unit is used for reading data from the lock-free queue by using a second thread, and encoding the read data according to a reading sequence to obtain data to be stored;
The storage unit is used for storing the data to be stored into a global message cache table;
The issuing unit is used for packaging the subscription request into an event to be processed as an event to be processed when receiving the subscription request initiated by the target client, and issuing the event to be processed to a target event driver corresponding to the target client;
A reading unit, configured to read, by using the target event driver, data corresponding to the event to be processed from the global message cache table as target data;
And the pushing unit is used for pushing the target data to the service system.
9. A computer device, the computer device comprising:
A memory storing at least one instruction; and
A processor executing instructions stored in the memory to implement the data subscription and push method of any one of claims 1 to 7.
10. A computer-readable storage medium, characterized by: the computer readable storage medium has stored therein at least one instruction for execution by a processor in a computer device to implement the data subscription and push method of any one of claims 1 to 7.
CN202410316299.5A 2024-03-20 2024-03-20 Data subscription and pushing method, device, equipment and medium Active CN117914943B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202410316299.5A CN117914943B (en) 2024-03-20 2024-03-20 Data subscription and pushing method, device, equipment and medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202410316299.5A CN117914943B (en) 2024-03-20 2024-03-20 Data subscription and pushing method, device, equipment and medium

Publications (2)

Publication Number Publication Date
CN117914943A true CN117914943A (en) 2024-04-19
CN117914943B CN117914943B (en) 2024-06-14

Family

ID=90686229

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202410316299.5A Active CN117914943B (en) 2024-03-20 2024-03-20 Data subscription and pushing method, device, equipment and medium

Country Status (1)

Country Link
CN (1) CN117914943B (en)

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104834506A (en) * 2015-05-15 2015-08-12 北京北信源软件股份有限公司 Method for processing business application through multiple threads
CN115623071A (en) * 2022-09-05 2023-01-17 浪潮软件集团有限公司 Method and system for distributing publish-subscribe messages of single machine and multiple clients
US11778000B1 (en) * 2013-03-25 2023-10-03 Junction Networks Inc. Event subscription in distributed session initiation protocol architectures
CN117608871A (en) * 2023-10-26 2024-02-27 长城证券股份有限公司 Financial quotation subscription method, equipment and medium based on shared memory message queue
CN117714532A (en) * 2023-11-27 2024-03-15 上海森浦信息服务有限公司 Data information pushing method based on Timeline model, gateway and related equipment

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US11778000B1 (en) * 2013-03-25 2023-10-03 Junction Networks Inc. Event subscription in distributed session initiation protocol architectures
CN104834506A (en) * 2015-05-15 2015-08-12 北京北信源软件股份有限公司 Method for processing business application through multiple threads
CN115623071A (en) * 2022-09-05 2023-01-17 浪潮软件集团有限公司 Method and system for distributing publish-subscribe messages of single machine and multiple clients
CN117608871A (en) * 2023-10-26 2024-02-27 长城证券股份有限公司 Financial quotation subscription method, equipment and medium based on shared memory message queue
CN117714532A (en) * 2023-11-27 2024-03-15 上海森浦信息服务有限公司 Data information pushing method based on Timeline model, gateway and related equipment

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
寇成坤;胡术;陈虹宇;李科磊;刘佳;: "ATC***中发布订阅***的设计与实现", 计算机工程与设计, no. 02, 16 February 2015 (2015-02-16) *

Also Published As

Publication number Publication date
CN117914943B (en) 2024-06-14

Similar Documents

Publication Publication Date Title
CN114124968B (en) Load balancing method, device, equipment and medium based on market data
CN112217639B (en) Data encryption sharing method and device, electronic equipment and computer storage medium
CN116755637B (en) Transaction data storage method, device, equipment and medium
CN116701233B (en) Transaction system testing method, equipment and medium based on high concurrency report simulation
CN113221154A (en) Service password obtaining method and device, electronic equipment and storage medium
CN112527908A (en) Block chain network construction method, node adding method, medium and equipment
CN117914943B (en) Data subscription and pushing method, device, equipment and medium
CN115731047B (en) Batch order processing method, equipment and medium
CN115269709B (en) Inquiry and playback method, device, equipment and medium based on market data
CN114741422A (en) Query request method, device, equipment and medium
CN113918517A (en) Multi-type file centralized management method, device, equipment and storage medium
CN116455997B (en) STEP market multipath forwarding method, STEP market multipath forwarding device, STEP market multipath forwarding equipment and STEP market multipath forwarding medium
CN116483747B (en) Quotation snapshot issuing method, device, equipment and medium
CN116455756B (en) Bandwidth equalization method, device and medium based on market push and inquiry
CN116361753B (en) Authority authentication method, device, equipment and medium
CN116843454B (en) Channel information management method, device, equipment and medium
CN115174698B (en) Market data decoding method, device, equipment and medium based on table entry index
CN115277610B (en) Message split sending method, device, equipment and medium based on dual-activity environment
CN116739611B (en) Customer information tracking management method, device, equipment and medium
CN118037453A (en) Order processing method, device, equipment and medium of transaction system
CN118014732A (en) Data return method, device, equipment and medium
CN118193493A (en) Service method, device, equipment and medium based on law enforcement event processing task
CN116401104A (en) Application data source switching method, device, equipment and medium
CN117874540A (en) Account feature-based same person identification method, device, equipment and medium
CN114389988A (en) Remote procedure call method, device, equipment and medium based on network architecture

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant