Distributed front and rear end real-time bidirectional communication and efficient data transmission method

By adopting distributed front-end and back-end real-time two-way communication and efficient data transmission methods in the online ride-hailing platform, and using middleware such as Netty and RocketMQ, the problem of frequent call of front-end servers in the existing technology is solved, real-time data synchronization and efficient transmission are achieved, and the real-time data access experience of operators is improved.

CN119544784APending Publication Date: 2025-02-28SHOUYUE TECH BEIJING CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411601916.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-11
Publication Date
2025-02-28

AI Technical Summary

Technical Problem

When the existing online ride-hailing platform is operating and customer service to solve problems, the backend system frequently calls the front-end server, resulting in an increase in the number of back-end server requests for no reason. The front-end acquisition of data is not real-time enough, occupying server and network bandwidth resources.

Method used

The distributed real-time two-way communication and efficient data transmission method of front-end and back-end are adopted. Through the front-end subscription event monitoring, the server is disconnected and reconnected, and the back-end starts multiple Netty servers and RocketMQ middleware, establish a long link and message push mechanism to ensure real-time data synchronization.

Benefits of technology

Real-time two-way communication of front-end services in distributed scenarios is realized, ensuring that operators see the data updated in the background in real time without refreshing the page. The selected middleware can not lose messages after the server is down and restarted, providing efficient data transmission and push functions.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119544784A_ABST
    Figure CN119544784A_ABST
Patent Text Reader

Abstract

The invention discloses a distributed front and back end real-time two-way communication and efficient data transmission method. The method comprises the following steps: S1, subscribing a corresponding event monitoring Event event by a front end; s2, the front end realizes offline reconnection with the server to prevent communication disconnection between the front end and the server end; s3, starting a plurality of Netty servers by the rear end, starting message monitoring, and creating different processing logics of each event; s4, an operator logs in a background system to open a corresponding page, and a front-end page carries the user Id to automatically establish a long link with a rear-end server; according to the invention, real-time two-way communication of front and rear end services in a distributed scene is realized; rocket MQ middleware is selected, even if a server crashes, the message is still not lost after the service is restarted, and the message can be pushed to the front end; and the front end can still establish connection with the server under the condition of network flash.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of online car-hailing platform operation, and specifically relates to a distributed front-end and back-end real-time two-way communication and efficient data transmission method. Background Art

[0002] In actual operations or when customer service solves problems, in order to see the company's operating data, a backend system will be built. From the backend system, operators can see the company's orders, drivers, GMV and other data. Operations also need to use the backend system to operate order assignments, bind drivers and vehicles, and review various materials uploaded by drivers. Some data changes dynamically. For example, when reviewing materials, it is necessary to call the services of third parties, and the results returned by the third parties are asynchronous. GMV also changes in real time. When manually assigning orders, the dispatch system also returns the result of successful assignment asynchronously. For the display of these dynamic data, the current practice is that the front-end page will continuously call the backend server to obtain the latest data.

[0003] The existing solution will increase the number of requests to the backend server for no reason; the time interval for the front-end to initiate polling requests is uncertain; the data obtained by the front-end is not real-time enough; more requests will occupy resources such as servers and network bandwidth.

[0004] To this end, the present invention designs a distributed front-end and back-end real-time two-way communication and efficient data transmission method. Summary of the invention

[0005] The object of the present invention is to provide a distributed front-end and back-end real-time two-way communication and efficient data transmission method to solve the problems raised in the above background technology.

[0006] To achieve the above object, the present invention provides the following technical solution: a distributed front-end and back-end real-time two-way communication and efficient data transmission method, S1: the front-end subscribes to the corresponding event to monitor the Event event;

[0007] S2: The front end implements disconnection reconnection with the server to prevent the front end from disconnecting from the server;

[0008] S3: The backend starts multiple Netty servers, starts message monitoring, and creates different processing logic for each event;

[0009] S4: The operator logs in to the backend system and opens the corresponding page. The frontend page will automatically establish a long link with the backend server with the userId.

[0010] S5: Websocket load balancing distributes the client connection in step S3 to the corresponding server instance according to the configured balancing strategy;

[0011] S6: The server saves the correspondence between userId and client in ConcurrentHashMap;

[0012] S7: The server adds userId to the corresponding group Room;

[0013] S8: Operation staff assigns orders to corresponding drivers in the background;

[0014] S9: After receiving the request, the backend service saves the corresponding data and notifies the dispatcher to assign the order;

[0015] S10: After the order is assigned successfully, the backend system will be notified asynchronously;

[0016] S11: The backend system verifies the authenticity of the data in step S9 and the landing of business data;

[0017] S12: The business of step S10 broadcasts the assignment result to RocketMQ after normal processing;

[0018] S13: The corresponding message is monitored and identified in the background system, and forwarded to the corresponding processing engine;

[0019] S14: The processing engine implements single-point message sending, message broadcasting, or message push to userId in certain Rooms according to its own business processing logic;

[0020] S15: The front-end in step S1 subscribes to the corresponding Event event, and then receives the data pushed by the back-end to render the page;

[0021] S16: The operator can see the background updated data in real time without refreshing the page.

[0022] Preferably, in step S1, the Event event includes message broadcast, message point-to-point sending, and user login.

[0023] Preferably, in step S6, ConcurrentHashMap is a data structure that stores the relationship between key and value in the format of [key: value].

[0024] Preferably, in step S4, the pages include an order list page, a GMV data page, and an order assignment page.

[0025] Preferably, ConcurrentHashMap is selected to prevent concurrency and errors caused by a large number of operators.

[0026] Preferably, RocketMQ is used to implement the data broadcast function and act as a DATA BUS.

[0027] Compared with the prior art, the present invention has the following beneficial effects: the present invention realizes real-time two-way communication between front-end and back-end services in a distributed scenario; the RocketMQ middleware is selected so that even if the server crashes, messages will not be lost after the service is restarted, and messages can be pushed to the front-end; in the event of a network outage, the front-end can still reconnect to the server. BRIEF DESCRIPTION OF THE DRAWINGS

[0028] Figure 1 It is a schematic diagram of the process of the present invention. DETAILED DESCRIPTION

[0029] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions 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 are within the scope of protection of the present invention.

[0030] See also Figure 1 , the present invention provides a technical solution: a distributed front-end and back-end real-time two-way communication and efficient data transmission method. The present invention summarizes the problems in the background system, selects Websocket, Netty, RocketMQ, JDK8 and the most commonly used SpringBoot ecosystem as the technical selection to perfectly solve the problems in the background system; when the client connects to the server, ConcurrentHashMap will be used to save the relationship between the userId of the login operation and the client channel Channel. If there is an order update, GMV update, or the assigned order has a return result, the corresponding data will be pushed to the corresponding operator who is concerned about the data using the Channel saved in ConcurrentHashMap.

[0031] Some updates require data broadcasting, that is, to notify all operators who are using the backend system. Since Netty is a stand-alone version, RocketMQ is used to implement data broadcasting. The changed data is sent to RocketMQ, and each server subscribes to the relevant data change notification. After receiving the notification, it can use the Channel saved in the ConcurrentHashMap to send the data to the corresponding operation.

[0032] The specific steps include:

[0033] S1: The front-end subscribes to the corresponding event monitoring, such as message broadcasting, message point-to-point sending, user login, referred to as Event;

[0034] S2: The front-end implements disconnection reconnection with the server to prevent the front-end from disconnecting from the server. Common methods include: heartbeat detection and retry;

[0035] S3: The backend starts multiple Netty servers, starts message monitoring, and creates different processing logic for each event;

[0036] S4: The operator logs in to the backend system and opens the corresponding page, such as the order list page, GMV data page, and assigned order page. The front-end page will automatically establish a long link with the back-end server with the userId;

[0037] S5: Websocket load balancing distributes S3 client connections to corresponding server instances based on the configured balancing strategy, such as polling and configuring server weights;

[0038] S6: The server saves the corresponding relationship between userId and the client in ConcurrentHashMap. ConcurrentHashMap is a data structure that saves the relationship between key and value in the format of [key: value].

[0039] S7: The server adds userId to the corresponding group, referred to as Room;

[0040] S8: Operation staff assigns orders to corresponding drivers in the background;

[0041] S9: After receiving the request, the backend service saves the corresponding data and notifies the dispatcher to assign the order;

[0042] S10: After the order is assigned successfully, the backend system will be notified asynchronously;

[0043] S11: The backend system verifies the authenticity of the data in step S9 and the landing of business data;

[0044] S12: The business of step S10 broadcasts the assignment result to RocketMQ after normal processing;

[0045] S13: The corresponding message monitor in the background system identifies this as the assignment result message, GMV data change information, etc., and forwards it to the corresponding processing engine;

[0046] S14: The processing engine implements single-point message sending, message broadcasting, or message push to userId in certain Rooms according to its own business processing logic;

[0047] S15: The front-end in step S1 subscribes to the corresponding Event event, and then receives the data pushed by the back-end to render the page;

[0048] S16: The operator can see the background updated data in real time without refreshing the page.

[0049] There are two types of message push involved in this solution: single-point data push; data broadcast;

[0050] ConcurrentHashMap is selected to prevent errors caused by concurrency when there are many operators;

[0051] RocketMQ is used to implement the data broadcast function and act as a DATA BUS.

[0052] Netty is used to enable two-way data communication between the front-end and back-end long links.

[0053] Although embodiments of the present invention have been shown and described, it will be appreciated by those skilled in the art that various changes, modifications, substitutions and variations may be made to the embodiments without departing from the principles and spirit of the present invention, and that the scope of the present invention is defined by the appended claims and their equivalents.

Claims

1. A distributed front-end and back-end real-time two-way communication and efficient data transmission method, characterized by: S1: The front end subscribes to the corresponding event listener Event; S2: The front end implements disconnection reconnection with the server to prevent the front end from disconnecting from the server; S3: The backend starts multiple Netty servers, starts message monitoring, and creates different processing logic for each event; S4: The operator logs in to the backend system and opens the corresponding page. The frontend page will automatically establish a long link with the backend server with the userId. S5: Websocket load balancing distributes the client connection in step S3 to the corresponding server instance according to the configured balancing strategy; S6: The server saves the correspondence between userId and client in ConcurrentHashMap; S7: The server adds userId to the corresponding group Room; S8: Operation staff assigns orders to corresponding drivers in the background; S9: After receiving the request, the backend service saves the corresponding data and notifies the dispatcher to assign the order; S10: After the order is assigned successfully, the backend system will be notified asynchronously; S11: The backend system verifies the authenticity of the data in step S9 and the landing of business data; S12: The business in step S10 broadcasts the assignment result to RocketMQ after normal processing; S13: The corresponding message is monitored and identified in the background system, and forwarded to the corresponding processing engine; S14: The processing engine implements single-point message sending, message broadcasting, or message push to userId in certain Rooms according to its own business processing logic; S15: The front-end in step S1 subscribes to the corresponding Event event, and then receives the data pushed by the back-end to render the page; S16: The operator can see the background updated data in real time without refreshing the page.

2. According to claim 1, a distributed front-end and back-end real-time two-way communication and efficient data transmission method is characterized by: In step S1, Event events include message broadcast, message point-to-point sending, and user login.

3. According to claim 1, a distributed front-end and back-end real-time two-way communication and efficient data transmission method is characterized by: In step S6, ConcurrentHashMap is a data structure that stores the relationship between key and value in the format of [key: value].

4. According to claim 1, a distributed front-end and back-end real-time two-way communication and efficient data transmission method is characterized by: In step S4, the pages include an order list page, a GMV data page, and an order assignment page.

5. According to claim 3, a distributed front-end and back-end real-time two-way communication and efficient data transmission method is characterized by: ConcurrentHashMap is selected to prevent concurrency and errors caused by a large number of operators.

6. A distributed front-end and back-end real-time two-way communication and efficient data transmission method according to claim 1, characterized in that: RocketMQ is used to implement the data broadcast function and act as a DATA BUS.