Real-time data pushing method, scheduling system, electronic equipment and storage medium
Through the unified management of client subscription requests and data docking of real-time communication services, the resource waste and complexity of front-end and back-end bidirectional real-time data communication in the microservice architecture is solved, and efficient communication and simplified development process is achieved.
Patent Information
- Application Number
- CN202411521918.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-29
- Publication Date
- 2025-01-03
AI Technical Summary
In the microservice architecture, with the refinement of service granularity, the two-way real-time data communication between the front-end and the back-end increases resource waste and code complexity, and the front-end needs to frequently establish long connections with multiple back-end services, resulting in The difficulty of development and maintenance is increased.
Through real-time communication services, we uniformly manage client subscription requests for different programming languages, and use multiple data docking methods (listening mode, subscription mode, timed polling mode) to obtain and push data from business services, reducing the direct interface between the front-end and the back-end and the long-term Connect, decouple the front-end and back-end to simplify development.
It realizes effective communication between the front-end and back-end, reduces resource waste and development complexity, is compatible with applications in different programming languages, simplifies the difficulty and code volume of business services development, and avoids the pressure of interface and connection management as the number of services increases.
Smart Images

Figure CN119254829A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of unified real-time data push, and in particular to a real-time data push method, a scheduling system, an electronic device and a storage medium. Background Art
[0002] With the continuous updating and iteration of technology and the increasing complexity of business, the system architecture has also evolved from traditional monolithic applications to distributed structures and then to the now popular microservice architecture. Microservice architecture is a distributed architecture system with loose coupling between applications, high autonomy between each application service, and sustainable integrated deployment using lightweight protocols for communication. Although the microservice architecture model can solve many problems for development, testing, and operation and maintenance personnel, it also adds some burdens.
[0003] On the one hand, as the granularity of services becomes smaller, if each application front-end and its corresponding server are to be able to communicate data in real time in both directions, the application front-end (usually the client) must establish a long connection with all back-end services. As the number of both application front-ends and back-end services continues to increase, the data communication interfaces between different ends will gradually increase, thereby causing a waste of resources for services at each end.
[0004] On the other hand, when the number of backends increases, the frontend needs to reconnect with the newly added backend services through data interfaces, which increases the cumbersome management of the application frontend code. Summary of the invention
[0005] The present invention provides a real-time data pushing method to solve the problem of unified real-time data pushing.
[0006] In a first aspect, the present invention provides a real-time data push method, which is applied to a scheduling system, wherein the scheduling system includes a front-end client, a middle-end real-time communication service, and a back-end business service, wherein the business service includes a plurality of sub-servers for executing services of different business types and producing business data; the real-time communication service is provided with a plurality of service components for supporting different data docking modes;
[0007] The method comprises:
[0008] The real-time communication service receives a subscription request sent by the client;
[0009] The real-time communication service determines a data connection mode between the real-time communication service and the business service based on a programming language used by the client;
[0010] The real-time communication service adopts the data connection mode and obtains the business data corresponding to the subscription request from the business service through the service component and sends the business data to the client.
[0011] In a second aspect, the present invention provides a scheduling system, the scheduling system includes a front-end client, a middle-end real-time communication service and a back-end business service, the business service includes a plurality of sub-servers that execute different business types and produce business data; the real-time communication service is provided with a plurality of service components for supporting different data docking modes;
[0012] The real-time communication service is used to receive a subscription request sent by the client; determine a data docking method between the real-time communication service and the business service based on a programming language used by the client; and obtain business data corresponding to the subscription request from the business service through the service component using the data docking method and send the data to the client.
[0013] In a third aspect, the present invention provides an electronic device, the electronic device comprising:
[0014] at least one processor; and
[0015] a memory communicatively connected to the at least one processor; wherein,
[0016] The memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute the real-time data push method described in the first aspect of the present invention.
[0017] In a fourth aspect, the present invention provides a computer-readable storage medium, wherein the computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the real-time data push method described in the first aspect of the present invention when executed.
[0018] In the above-mentioned real-time data push method, the real-time communication service serves as the middle end between the client (front end) and the business service (back end). Since the real-time communication service is provided with multiple service components for supporting different data docking methods, the real-time communication service can uniformly manage subscription requests initiated by clients using different programming languages. On the basis of enabling the front-end client and the back-end business service to communicate effectively, the front-end client is decoupled from the back-end business service. The front-end client does not need to dock with numerous back-end business services, and does not need to maintain multiple long connections with multiple back-end sub-servers, thereby reducing the complexity of joint debugging brought by front-end development. In addition, since the business service usually has a large number of sub-servers, the real-time push service uniformly handles subscription requests from different clients, and each sub-server in the business service does not need to repeatedly write the code for interacting with the front end, thereby simplifying the development difficulty of the business service and reducing the workload of code development. Whether the number of front-ends or back-ends increases, there is no need to add corresponding data interfaces at the other end (front-end or back-end), saving resources of each end service.
[0019] It should be understood that the contents described in this section are not intended to identify the key or important features of the embodiments of the present invention, nor are they intended to limit the scope of the present invention. Other features of the present invention will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0021] Figure 1 is a structural diagram of a scheduling system provided by an embodiment of the present invention;
[0022] Figure 2 is a flow chart of a real-time data push method provided by an embodiment of the present invention;
[0023] Figure 3 This is a data push timing diagram when the data connection mode is a monitoring mode provided by an embodiment of the present invention;
[0024] Figure 4 This is a data push timing diagram when a data connection mode is a subscription mode provided by an embodiment of the present invention;
[0025] Figure 5 This is a data push timing diagram when a data connection mode provided by an embodiment of the present invention is a timed polling mode;
[0026] Figure 6This is a data push timing diagram for communication between two clients provided by an embodiment of the present invention;
[0027] Figure 7 It is a schematic diagram of data flow when the scheduling system provided by an embodiment of the present invention pushes data to front ends implemented in different programming languages;
[0028] Figure 8 It is a schematic diagram of the structure of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0029] In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.
[0030] Figure 1 A schematic diagram of a scheduling system provided by an embodiment of the present invention is shown in FIG. Figure 1 As shown, the scheduling system includes a front-end client 10, a middle-end real-time communication service 20 and a back-end business service 30. The business service 30 includes a plurality of sub-servers for executing services of different business types and producing business data.
[0031] The client 10 can display the system page and exchange data with the real-time communication service 20 through a long connection. For example, the client 10 initiates a subscription request to the real-time communication service 20, and the real-time communication service 20 pushes relevant data to the client 10;
[0032] The real-time communication service 20 is provided with multiple service components for supporting different data connection modes. The service components are third-party service components, which facilitate data transmission between services through message queues, caches, etc. The real-time communication service 20 receives requests from clients, manages subscriptions, pushes, and unsubscribes from clients, and receives data transmitted by the business service 30 through service components. The present invention mainly describes the process of the client 10 sending a subscription request and obtaining business data. The subscription request mainly includes the client ID, client name, business type, etc.
[0033] The business service 30 is a data producer, which obtains data required by the real-time communication service 20 through the service components in the real-time communication service 20, produces corresponding data, and pushes the data to the real-time communication service 20 through the service components.
[0034] The number and type of the client 10 can be multiple, and the number and type of the sub-servers in the business service 30 can also be multiple, and the type of the sub-server usually corresponds to the type of the client. For example, the client 10 can be a passenger flow monitoring client, a vehicle driving monitoring client, a device monitoring client, etc. Correspondingly, the sub-server can be a passenger flow monitoring sub-server, a vehicle driving monitoring sub-server, a device monitoring sub-server, etc.
[0035] Figure 2 This is a flowchart of a real-time data push method provided by an embodiment of the present invention. This embodiment is applicable to the case of unified push of real-time data of clients and business services. The method can be executed by a scheduling system, which can be implemented in the form of hardware and / or software, and can be configured in an electronic device. Figure 2 As shown, the real-time data push method includes:
[0036] S101: The real-time communication service receives a subscription request sent by a client.
[0037] Before the client sends a subscription request, the client also establishes a connection with the real-time communication service. The client and the real-time communication service exchange data through a persistent connection, which is mainly implemented through the Websocket protocol, heartbeat mechanism, long polling, etc.
[0038] In addition, the client can also send push requests and unsubscribe requests to the real-time push service.
[0039] S102: Determine a data connection method between the real-time communication service and the business service based on the programming language used by the client.
[0040] After the client sends a subscription request to the real-time communication service, the real-time communication service needs to obtain the corresponding business data from the business service and return it to the client, that is, data interaction is required. In programming, data interaction usually involves reading and writing data to different data sources, etc. The programming language of the client may be HTML5, C#, Jsp, Android, Ios, etc. The number of clients may be large, and different clients may use different programming languages. Some message middleware (components) can only be used for front-end applications implemented in some programming languages (such as C#), while front-ends implemented in some programming languages cannot use message components. Taking HTML5 as an example, the front-end implemented in HTML5 language can only use Websocket for data interaction and cannot use message middleware. Therefore, when interacting with the client, the real-time communication service can determine the data docking mode based on the programming language used by the client, so that the business data finally obtained can be successfully received by the client. Specifically, the data docking mode can be a monitoring mode, a subscription mode, and a timed polling mode to adapt to front-ends (clients) implemented in different programming languages.
[0041] S103: The real-time communication service uses a data connection method to obtain business data corresponding to the subscription request from the business service through the service component and feeds back the data to the client.
[0042] The real-time communication service is provided with multiple service components for supporting different data docking methods. Therefore, after determining the data docking method, the corresponding service components can be combined to obtain the business data corresponding to the subscription request from the business service using the data docking method. The business data obtained in this data docking method is compatible with the programming language of the client, so that the business data can be read by the client and written to the data source, etc. Specifically, the real-time communication service can determine the specific business service (for example, passenger service, passenger flow service, driving service, etc.) that needs to be called according to the subscription request information of the client, and after finding the specific business service, determine the data docking method between the real-time communication service and the specific back-end service, and obtain the data according to the selected data docking method and push it to the client in real time.
[0043] In the above-mentioned real-time data push method, the real-time communication service is used as the middle end between the client (front end) and the business service (back end). Since the real-time communication service is provided with multiple service components for supporting different data docking modes, the real-time communication service can uniformly manage the subscription requests initiated by the clients using different programming languages. On the basis of enabling the front-end client and the back-end business service to communicate effectively, the front-end client and the back-end business service are decoupled. On the one hand, the scheduling system can be compatible with the front-end applications developed in different languages and can perform two-way data communication with the back-end services implemented in different languages. On the other hand, the front-end client does not need to dock with a large number of back-end business services, and does not need to maintain multiple long connections established with multiple back-ends, which reduces the complexity of joint debugging brought by front-end development. In addition, since the business service usually has a large number of sub-servers, the real-time push service uniformly processes the request information (subscription request) of different clients, and each sub-server in the business service does not need to repeatedly write the code for interacting with the front end, which simplifies the development difficulty of the business service and reduces the workload of code development. Whether the number of front-ends or back-ends increases, there is no need to add corresponding data interfaces at the other end (front-end or back-end), saving resources of each end service.
[0044] In an optional embodiment, the real-time communication service includes multiple service nodes, which are a group of computer devices or software programs responsible for receiving, processing and forwarding task requests, data and information in a certain network. Figure 1 As shown, the real-time communication service includes service node 1, service node 2, service node 3, etc. The service node is used to support the connection between the client and the sub-server. The essence of the service node is an interface that is open to the outside and provides external services.
[0045] The client's request information (subscription request) is distributed to the service node through a hash algorithm. The basic principle of the hash ring is to map all nodes and data to a ring, and each node and data has a corresponding hash value on the ring. When you need to access a certain data, map the hash value of the data to the ring, and then find the first node with a larger hash value along the clockwise direction of the ring. This node is the node where the data is located. If you need to add or delete a node, you only need to recalculate the hash value of the node and data and redistribute it on the ring.
[0046] When the number of front-end applications and back-end services carried by the real-time communication service is too large, the real-time communication service may cause the service to crash because it cannot handle it. In order to avoid this situation, the real-time communication service in the embodiment of the present invention needs to support the dynamic expansion deployment of service nodes and process data transmission through some load strategies. In order to ensure that each request information can be evenly loaded to each service node, the real-time communication service of the present invention introduces a consistent hashing algorithm, and all service nodes of the real-time communication service are dynamically deployed on the hash ring. Each time the front-end (client) application initiates a request, it can hit a specific service node. At the same time, when some nodes hang up (fail or fail), the hash ring will also update and delete the hanging nodes in real time to ensure that each request from the front end will not be lost.
[0047] like Figure 1 As shown, the real-time communication service 20 may be provided with multiple service components for supporting different data docking modes. The service component is a third-party service component. The essence of the component is a reusable encapsulation that facilitates data transmission between services through message middleware, cache, etc. The service component includes a message queue (Message Queue), a distributed cache, and a webocket component, wherein the distributed cache includes at least one of a Redis cache and a Memcached cache.
[0048] In order to clearly describe the interaction between the front end (client) using different programming languages, the real-time communication service and the business service, the following embodiments are used for illustration.
[0049] In an optional embodiment, a distributed cache and a message queue are provided in the real-time communication service. When the data connection mode is the monitoring mode, the real-time communication service obtains the business data corresponding to the request information from the business service by the data connection mode and feeds it back to the client, including:
[0050] Business services send updated business data to the distributed cache in real time;
[0051] The real-time communication service monitors the business data corresponding to the subscription request from the distributed cache as the target business data;
[0052] The real-time communication service pushes the target business data to the client, or the real-time communication service sends the target business data to a message queue, so that the client monitors the target business data from the message queue.
[0053] Specifically, when a service node in a real-time communication service receives a subscription request, it filters (listens to) the business data corresponding to the subscription request from the distributed cache, and then pushes the business data to the client through the service node. It should be noted here that when the client establishes a connection with the service node, the service node obtains the client-related identity information (such as the client ID) and stores it in the distributed cache for management. When a specific subscription request is received, the service node filters out the business data corresponding to the subscription request in the distributed cache and feeds it back to the client. The real-time communication service pushes the target business data to the client, or the real-time communication service sends the target business data to the message queue so that the client can monitor the target business data from the message queue. Here, it means that the real-time communication service still has two processing methods after obtaining the target business data, which can be specifically executed according to the programming language of the client. For example, when the programming language of the client is HTML5, the client cannot directly monitor the data from the message queue. Therefore, the real-time communication service can only send data to the client. When the programming language of the client is C#, the client can directly monitor the data from the message queue. Therefore, the real-time communication service can send data to the client, or the real-time communication service can first send the data to the message queue, and then the client actively monitors the corresponding message queue to obtain the data. It can adapt to the front end implemented in different programming languages.
[0054] Figure 3 This is the data push timing diagram when the data connection mode is the monitoring mode. Figure 3 In the code, C# and HTML5 indicate that the programming language of the client is C# or HTML5. The "C#" before the step number indicates that this step is only for the client whose programming language is C#. Figure 3 As shown, when the programming language of the client is C# or HTML5, the data push process may include the following steps:
[0055] 1. The client establishes a connection with the service node (in the real-time push service);
[0056] When establishing a connection, the service node stores the client's identity information in the distributed cache for management, so as to push information to the client in the subsequent process;
[0057] 2. The client initiates a subscription (request) to the service node;
[0058] 3. The service node obtains the subscription (request) data through websocket and stores it in the distributed cache;
[0059] Subscription data includes the client's identity information and business data type.
[0060] 4. The business service sends the updated business data to the distributed cache.
[0061] 5. The service node obtains relevant business data from the distributed cache through websocket.
[0062] The relevant business data is the business data corresponding to the subscription (request) data;
[0063] 6.1. The service node pushes the acquired business data to the client.
[0064] Because the programming language of the client is HTML5, HTML5 can only use websocket to obtain data, and cannot use message middleware such as message queues. The business data pushed by the service node is also obtained through websocket. Therefore, the client can receive the business data and perform data processing, including data reading and writing. Among them, WebSocket is an important feature of HTML5, which allows a persistent connection to be established between the client and the server, so that data can be exchanged in real time in a two-way form. Compared with traditional HTTP communication, WebSocket connection can reduce latency and improve efficiency. In the WebSocket API, the browser and the server only need to complete a handshake, and a persistent connection can be directly created between the two, and two-way data transmission can be performed.
[0065] The above is a data push method, which can be compatible with data push to clients using C# and HTML5 programming languages. In another data push method, when the client programming language is C#, Figure 3 As shown, after step 5, the following steps may also be included:
[0066] 6.2. The service node sends relevant business data to the message queue;
[0067] 7. The client actively monitors business data from the message queue.
[0068] When the programming language of the client is C#, the service node in the real-time communication service filters out the business data corresponding to the subscription request from the distributed cache when receiving the subscription request. When the client obtains data, the business data can be sent to the client through the service node, or sent to the message queue specified by the client for listening, so that the client can receive the data in the message queue when listening to the specified message queue.
[0069] In an optional embodiment, a message queue is provided in the real-time communication service. When the data connection mode is a subscription mode, the real-time communication service adopts the data connection mode, obtains the business data corresponding to the subscription request from the business service through the service component and feeds it back to the client, including:
[0070] The real-time communication service sends the subscription request to the message queue;
[0071] The business service listens to the subscription request in the message queue and publishes the target business data corresponding to the subscription request to the message queue;
[0072] The real-time communication service listens to and subscribes to target business data from the message queue and pushes it to the client, or the client listens to the target business data from the message queue.
[0073] For example, when the client's programming language is HTML5, the client cannot subscribe (listen) to data directly from the message queue, so the real-time communication service can only send data to the client. When the client's programming language is C#, the client can directly listen to data from the message queue. Therefore, the real-time communication service can send data to the client, or the real-time communication service can first send data to the message queue, and then the client actively listens to the corresponding message queue to obtain data, which can adapt to front ends implemented in different programming languages. On the basis of successfully pushing data to the client, different selection methods of the client for pushing data can be met.
[0074] Figure 4 This is a data push sequence diagram when the data connection mode is the subscription mode. Figure 4 In the code, C# and HTML5 indicate that the programming language of the client is C# or HTML5. The "C#" before the step number indicates that this step is only for the client whose programming language is C#. Figure 4 As shown, when the programming language of the client is C# or HTML5, the data push process may include the following steps:
[0075] 1. The client establishes a connection with the service node (in the real-time push service);
[0076] 2. The client initiates a subscription (request) to the service node;
[0077] 3. The service node sends the request to the message queue;
[0078] 4. The business service listens to the message queue for requests and receives them.
[0079] 5. The business service sends the business data corresponding to the request to MQ (message queue).
[0080] The relevant business data is the business data corresponding to the subscription (request) data;
[0081] 6.2. The service node monitors business data from the message queue through websocket.
[0082] 7. The service node pushes the business data to the client.
[0083] The above is a data push method, which is compatible with data push of clients using C# and HTML5 programming languages. In another data push method, when the client programming language is C#, Figure 4 As shown, after step 5, the following steps may also be included:
[0084] 6.1. The client monitors business data from the message queue.
[0085] It can be seen that when the client's programming language is C#, business data can be sent to the client through the service node, or the client can directly monitor the business data in the specified message queue. On the basis of successfully pushing data to the client, the client's different choices for pushing data can be met.
[0086] The above process involves monitoring of the message queue. The basic principle of monitoring the message queue is: the sender (service node) sends the message to the specified queue, and the receiver (client) obtains the message by monitoring the queue. When the sender sends a message to the queue, the message is stored in the queue. The receiver monitors the queue. When new messages enter the queue, the receiver will receive notifications and process these messages, which can realize real-time data push.
[0087] In an optional embodiment, the sub-server in the business service is provided with a Restful interface, the real-time communication service pre-configures the call parameters of the Restful interface of each sub-server into a database, and a message queue is provided in the real-time communication service.
[0088] When the data connection mode is the scheduled polling mode, the real-time communication service adopts the data connection mode, obtains the business data corresponding to the subscription request from the business service through the service component and feeds it back to the client, including:
[0089] The real-time communication service matches the RESTful interface of the sub-server corresponding to the subscription request and the call parameters corresponding to the RESTful interface in the database.
[0090] The real-time communication service periodically accesses the Restful interface according to the call parameters corresponding to the Restful interface to obtain the target business data corresponding to the subscription request;
[0091] The real-time communication service pushes the target business data to the client, or the real-time communication service sends the target business data to a message queue, so that the client monitors the target business data from the message queue.
[0092] The call parameters may include polling additional request headers, polling time intervals (e.g., every 5 seconds or 10 seconds), topics, etc. When the call interface is determined, the data call path is determined, and after the call parameters corresponding to the interface are determined, the data call method is determined. Therefore, the real-time communication service can directly access the call interface in combination with the call parameters to obtain the required business data.
[0093] Figure 5 This is the data push timing diagram when the data connection mode is the timed polling mode. Figure 5 In the code, C# and HTML5 indicate that the programming language of the client is C# or HTML5. The "C#" before the step number indicates that this step is only for the client whose programming language is C#. Figure 5 As shown, when the programming language of the client is C# or HTML5, the data push process may include the following steps:
[0094] 1. The client establishes a connection with the service node (in the real-time push service);
[0095] 2. The client initiates a subscription (request) to the service node;
[0096] 3. The service node accesses the restful interface to obtain data;
[0097] Specifically, the service node accesses the interface through the determined restful interface and the call parameters corresponding to the interface to obtain (business) data.
[0098] 4.1. The service node pushes the acquired data to the client.
[0099] The above is a data push method under the timed polling mode, which can be compatible with data push of clients in C# and HTML5 programming languages. In another data push method under the timed polling mode, when the client programming language is C#, such as Figure 5 As shown, after step 3, the following steps may also be included:
[0100] 4.2. The service node sends the obtained data to MQ (message queue).
[0101] 5. The client monitors business data from the message queue.
[0102] It can be seen that when the client's programming language is C#, business data can be sent to the client through the service node, or the client can directly monitor the business data in the specified message queue. On the basis of successfully pushing data to the client, the client's different choices for pushing data can be met.
[0103] In an optional embodiment, a websocket component is further provided in the real-time communication service, and the clients all establish a connection with the real-time communication service through the websocket component, and the clients include a first client and a second client other than the first client;
[0104] Real-time data push methods also include:
[0105] The first client initiates a communication request to the websocket component in the real-time communication service;
[0106] When the websocket component receives the communication request, it pushes the client ID list of the second client to the first client service end;
[0107] The first client determines the second client to which data is to be sent according to the client ID list, obtains the target client, generates communication data according to the target client, and sends the communication data to the websocket component;
[0108] The websocket component pushes communication data to the target client.
[0109] The programming languages used by the first client and the second client may be the same or different.
[0110] It should be noted that the first client refers to the client that sends data, and the second client refers to the client that can receive data from the first client. The second client is the client that establishes a connection with the websocket component. The websocket component pushes the client ID list of the second client to the first client service end. On the one hand, it indicates that the clients in the ID list have communication permissions. On the other hand, it provides the first client with options for the clients to which data is to be sent. The first client selects the client to which data needs to be sent, which can avoid data being sent by mistake.
[0111] Figure 6 This is a timing diagram of data push when communicating between two clients, such as Figure 6 As shown, the communication between two clients specifically includes the following steps:
[0112] 1. The first client establishes a connection with the websocket component.
[0113] 2. The first client initiates a subscription to the websocket component.
[0114] 3. The websocket component pushes the second client ID list to the first client.
[0115] 4. The first client sends the data sent to other clients to the websocket component.
[0116] 5. The websocket component pushes the received data to the second client.
[0117] In a chat scenario, the second client ID list is a user name. The user of the first client selects the ID to which he wants to send a chat message from the second client ID list and enters the specific chat content, which is sent to the websocket component as data to be sent to other clients. The websocket component sends the received data to the client ID specified by the first client, so that the specific chat content can be received by the second client corresponding to the specified client ID and browsed by the user at the second client.
[0118] It should be noted that the embodiments of the present invention mainly use clients of the two programming languages C# and HTML5 as examples, which is not a limitation on the clients of the programming languages to which the scheme of the present invention is applicable. The scheme of the present invention can also be applied to clients of programming languages such as Jsp, Android, and Ios.
[0119] In summary, for clients using different programming languages, to achieve real-time data push to clients and communication between clients, the specific solutions can be briefly summarized as follows: Figure 7 middle, Figure 7 FIG. 1 is a schematic diagram of data flow when the scheduling system of an embodiment of the present invention pushes data to front ends implemented in different programming languages, such as Figure 7 As shown, it can be seen that, in general, the data push process is:
[0120] 1. Different clients (such as C# and HTML5) initiate subscriptions to the real-time communication service, and the real-time communication service uniformly maintains the subscription requests of each client;
[0121] 2. The real-time communication service determines the specific business service that needs to be called (such as passenger service, passenger flow service, driving service, etc.) based on the client's subscription request information. After finding the specific business service, it determines the data connection method between the real-time communication service and the specific back-end service. It selects one or more of the three methods to obtain data and push it to the client in real time.
[0122] like Figure 7 As shown in the figure, real-time data push includes the following three methods:
[0123] Method 1: The real-time communication service is connected to the specific business service. Through the distributed cache (such as Memcached), the business service actively pushes data to the cache in real time. The real-time communication service receives the business data subscribed by the client in the monitoring mode and pushes it to the specific subscribed client in real time. The client displays the data in real time.
[0124] Method 2: The real-time communication service and the specific business service publish and subscribe through the message queue middleware. The business service publishes data to the message queue in real time. The real-time communication service receives the information subscribed to the message queue according to the client's subscription information and pushes it to the specific subscribed client.
[0125] Method 3: The real-time communication service and the specific business service are connected through the restful interface to realize the push of real-time data. The real-time communication service configures the data interfaces of different business services in the database in advance, including the data interface name, input parameters, output parameters and push frequency. The real-time communication service finds the specific data interface configured in the database according to the information subscribed by the client, and polls the specific business service regularly according to the configured frequency to obtain data and push it to the specific client;
[0126] In the real-time data push method of the present invention, the real-time communication service unifies the subscription service, and is compatible with different application terminals implemented by different programming languages (H5, C#, Jsp, Android, Ios, etc.) and back-end services to establish a two-way communication protocol. In addition, the real-time communication service supports a variety of technical components for back-end services, including: message queues, distributed caches (Memcached, Redis), Restful interface polling, etc. Clients implemented in different programming languages can select an adapted data docking mode to interact with business data to achieve real-time data push.
[0127] Corresponding to the real-time data push method, the present invention also provides a scheduling system, Figure 1 This is a schematic diagram of the structure of a scheduling system provided by Embodiment 3 of the present invention. Figure 1 As shown, the scheduling system includes:
[0128] The scheduling system includes a front-end client 10, a middle-end real-time communication service 20 and a back-end business service 30. The business service 30 includes a plurality of sub-servers for executing different business types and producing business data. The real-time communication service 20 is provided with a plurality of service components for supporting different data docking modes.
[0129] Specifically, the real-time communication service is used to receive a subscription request sent by the client; determine a data docking method between the real-time communication service and the business service based on a programming language used by the client; and adopt the data docking method and obtain business data corresponding to the subscription request from the business service through the service component and send it to the client.
[0130] Optionally, the client is further used to establish a connection with the real-time communication service.
[0131] Optionally, the real-time communication service is provided with a distributed cache and a message queue, and when the data connection mode is a monitoring mode,
[0132] The business service is used to send updated business data to the distributed cache in real time;
[0133] The real-time communication service is used to monitor the service data corresponding to the subscription request from the distributed cache as the target service data;
[0134] The real-time communication service is used to push the target service data to the client, or the real-time communication service sends the target service data to a message queue so that the client can monitor the target service data from the message queue.
[0135] Optionally, a message queue is provided in the real-time communication service, and when the data connection mode is a subscription mode,
[0136] The real-time communication service is used to send the subscription request to a message queue;
[0137] The business service is used to monitor the subscription request in the message queue and publish the target business data corresponding to the subscription request to the message queue;
[0138] The real-time communication service is used to monitor and subscribe to the target business data from the message queue and push it to the client, or the client monitors the target business data from the message queue.
[0139] Optionally, the sub-server in the business service is provided with a Restful interface, the real-time communication service pre-configures the call parameters of the Restful interface of each sub-server into a database, and the real-time communication service is provided with a message queue. When the data connection mode is a timed polling mode,
[0140] The real-time communication service is used to match the RESTful interface of the sub-server corresponding to the subscription request and the call parameters corresponding to the RESTful interface in the database;
[0141] The real-time communication service is used to periodically access the Restful interface according to the call parameters corresponding to the Restful interface to obtain the target service data corresponding to the subscription request;
[0142] The real-time communication service is used to push the target service data to the client, or the real-time communication service sends the target service data to a message queue so that the client can monitor the target service data from the message queue.
[0143] Optionally, the real-time communication service is further provided with a websocket component, and the clients all establish a connection with the real-time communication service through the websocket component, and the clients include a first client and a second client other than the first client;
[0144] The first client is used to initiate a communication request to the websocket component in the real-time communication service;
[0145] The websocket component is used to push the client ID list of the second client to the first client service end when receiving the communication request;
[0146] The first client is used to determine the second client to which data is to be sent according to the client ID list, obtain a target client, and generate communication data according to the target client and send it to the websocket component;
[0147] The websocket component is used to push the communication data to the target client.
[0148] Optionally, a plurality of service nodes are provided in the real-time communication service, and the service nodes are used to support the connection between the client and the sub-server in the business service. The real-time communication service distributes the subscription request of the client to the service node through a hash algorithm.
[0149] The scheduling system provided by the embodiment of the present invention can execute the real-time data push method provided by any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of the execution method.
[0150] Figure 8 A schematic diagram of an electronic device 40 that can be used to implement an embodiment of the present invention is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present invention described and / or required herein.
[0151] like Figure 8As shown, the electronic device 40 includes at least one processor 41, and a memory connected to the at least one processor 41, such as a read-only memory (ROM) 42, a random access memory (RAM) 43, etc., wherein the memory stores a computer program that can be executed by at least one processor, and the processor 41 can perform various appropriate actions and processes according to the computer program stored in the read-only memory (ROM) 42 or the computer program loaded from the storage unit 48 to the random access memory (RAM) 43. In the RAM 43, various programs and data required for the operation of the electronic device 40 can also be stored. The processor 41, the ROM 42, and the RAM 43 are connected to each other through a bus 44. An input / output (I / O) interface 45 is also connected to the bus 44.
[0152] A number of components in the electronic device 40 are connected to the I / O interface 45, including: an input unit 46, such as a keyboard, a mouse, etc.; an output unit 47, such as various types of displays, speakers, etc.; a storage unit 48, such as a disk, an optical disk, etc.; and a communication unit 49, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 49 allows the electronic device 40 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.
[0153] The processor 41 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the processor 41 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, digital signal processors (DSPs), and any appropriate processors, controllers, microcontrollers, etc. The processor 41 executes the various methods and processes described above, such as a real-time data push method.
[0154] In some embodiments, the real-time data push method can be implemented as a computer program, which is tangibly contained in a computer-readable storage medium, such as a storage unit 48. In some embodiments, part or all of the computer program can be loaded and / or installed on the electronic device 40 via the ROM 42 and / or the communication unit 49. When the computer program is loaded into the RAM 43 and executed by the processor 41, one or more steps of the real-time data push method described above can be performed. Alternatively, in other embodiments, the processor 41 can be configured to perform the real-time data push method in any other appropriate manner (e.g., by means of firmware).
[0155] Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), complex programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.
[0156] Computer programs for implementing the methods of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that when the computer program is executed by the processor, the functions / operations specified in the flow chart and / or block diagram are implemented. The computer program may be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.
[0157] In the context of the present invention, a computer-readable storage medium may be a tangible medium that may contain or store a computer program for use by or in combination with an instruction execution system, device or equipment. A computer-readable storage medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices or equipment, or any suitable combination of the foregoing. Alternatively, a computer-readable storage medium may be a machine-readable signal medium. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0158] To provide interaction with a user, the systems and techniques described herein may be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and a pointing device (e.g., a mouse or trackball) through which the user can provide input to the electronic device. Other types of devices may also be used to provide interaction with the user; for example, the feedback provided to the user may be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form (including acoustic input, voice input, or tactile input).
[0159] The systems and techniques described herein may be implemented in a computing system that includes backend components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes frontend components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such backend components, middleware components, or frontend components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), a blockchain network, and the Internet.
[0160] A computing system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The client and server relationship is generated by computer programs running on the corresponding computers and having a client-server relationship with each other. The server may be a cloud server, also known as a cloud computing server or cloud host, which is a host product in the cloud computing service system to solve the defects of difficult management and weak business scalability in traditional physical hosts and VPS services.
[0161] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps described in the present invention can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solution of the present invention can be achieved, and this document does not limit this.
[0162] The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.
Claims
1. A real-time data push method, characterized in that: Applied to the dispatching system, the dispatching system includes a front-end client, a middle-end real-time communication service and a back-end business service, the business service includes multiple sub-servers that execute different types of business and produce business data; The real-time communication service is provided with a plurality of service components for supporting different data connection modes; The method comprises: The real-time communication service receives a subscription request sent by the client; The real-time communication service determines a data connection mode between the real-time communication service and the business service based on a programming language used by the client; The real-time communication service adopts the data connection mode and obtains the business data corresponding to the subscription request from the business service through the service component and sends the business data to the client.
2. The method according to claim 1, characterized in that Before the real-time communication service receives the subscription request sent by the client, the method further includes: The client establishes a connection with the real-time communication service.
3. The method according to claim 1, characterized in that The real-time communication service is provided with a distributed cache and a message queue. When the data connection mode is the monitoring mode, the real-time communication service adopts the data connection mode, obtains the business data corresponding to the subscription request from the business service through the service component and feeds back the business data to the client, including: The business service sends updated business data to the distributed cache in real time; The real-time communication service monitors the service data corresponding to the subscription request from the distributed cache as target service data; The real-time communication service pushes the target service data to the client, or the real-time communication service sends the target service data to a message queue, so that the client monitors the target service data from the message queue.
4. The method according to claim 1, characterized in that The real-time communication service is provided with a message queue. When the data connection mode is a subscription mode, the real-time communication service adopts the data connection mode, obtains the business data corresponding to the subscription request from the business service through the service component and feeds back the business data to the client, including: The real-time communication service sends the subscription request to a message queue; The business service monitors the subscription request in the message queue, and publishes the target business data corresponding to the subscription request to the message queue; The real-time communication service monitors and subscribes to the target service data from the message queue and pushes the target service data to the client, or the client monitors the target service data from the message queue.
5. The method according to claim 1, characterized in that The sub-server in the business service is provided with a Restful interface, the real-time communication service pre-configures the calling parameters of the Restful interface of each sub-server into a database, and the real-time communication service is provided with a message queue. When the data connection mode is a timed polling mode, the real-time communication service adopts the data connection mode, obtains the business data corresponding to the subscription request from the business service through the service component and feeds back the business data to the client, including: The real-time communication service matches the RESTful interface of the sub-server corresponding to the subscription request and the call parameters corresponding to the RESTful interface in the database; The real-time communication service periodically accesses the Restful interface according to the call parameters corresponding to the Restful interface to obtain the target service data corresponding to the subscription request; The real-time communication service pushes the target service data to the client, or the real-time communication service sends the target service data to a message queue, so that the client monitors the target service data from the message queue.
6. The method according to any one of claims 1 to 5, characterized in that: The real-time communication service is also provided with a websocket component, and the clients all establish a connection with the real-time communication service through the websocket component, and the clients include a first client and a second client other than the first client; The method further comprises: The first client initiates a communication request to the websocket component in the real-time communication service; When receiving the communication request, the websocket component pushes the client ID list of the second client to the first client service end; The first client determines the second client to which data is to be sent according to the client ID list, obtains a target client, generates communication data according to the target client, and sends the communication data to the websocket component; The websocket component pushes the communication data to the target client.
7. The method according to any one of claims 1 to 5, characterized in that: The real-time communication service is provided with a plurality of service nodes, and the service nodes are used to support the connection between the client and the sub-server in the business service. The real-time communication service distributes the subscription request of the client to the service node through a hash algorithm.
8. A scheduling system, characterized in that: The scheduling system includes a front-end client, a middle-end real-time communication service and a back-end business service. The business service includes multiple sub-servers that execute different types of business and produce business data. The real-time communication service is provided with multiple service components for supporting different data docking methods. The real-time communication service is used to receive a subscription request sent by the client; Determining a data connection method between the real-time communication service and the business service based on a programming language used by the client; The data connection method is adopted to obtain the business data corresponding to the subscription request from the business service through the service component and send it to the client.
9. An electronic device, characterized in that: The electronic device comprises: at least one processor; and a memory communicatively connected to the at least one processor; wherein, The memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute the real-time data pushing method according to any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the real-time data push method according to any one of claims 1 to 7 when executed.
Citation Information
Cited By
Real-time data transmission method, device, electronic equipment and system
CN120602465A
A real-time data transmission method, apparatus, electronic device and system
CN120602465B