Cross-subnet communication method and device, electronic device and storage medium
By dividing priority sharding queues and proxy centers in cross-network segment communication, and combining them with intelligent routing mechanisms, the queue blocking problem caused by sequential consumption in RabbitMQ is solved, achieving efficient and reliable cross-network segment communication and ensuring rapid response to critical business messages and system stability.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- TRAVELSKY TECHNOLOGY LIMITED
- Filing Date
- 2025-08-07
- Publication Date
- 2026-06-23
AI Technical Summary
In cross-network segment communication, RabbitMQ's first-in-first-out consumption mechanism causes queue message blocking, resulting in low business processing efficiency and poor communication reliability. Especially when dealing with a large number of concurrent requests and priority-sensitive communication scenarios, the delay of high-priority messages affects business processing.
A cross-network segment communication method is adopted, which divides the first type of network segment into N fragment queues, and further divides them into first-level, second-level and third-level fragment queues according to priority. Combined with a proxy center and intelligent routing mechanism, high-priority messages are processed quickly. When the communication path is unreachable, a backup path is switched to avoid communication interruption caused by single point of failure.
It improves the system's real-time response capability and business processing efficiency, enhances communication reliability and stability, supports data exchange in large-scale high-concurrency scenarios, reduces message blocking issues, and ensures rapid response to critical business messages.
Smart Images

Figure CN120896910B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of communication technology or other related technical fields. Specifically, it relates to a cross-network segment communication method and apparatus, electronic device and storage medium. Background Technology
[0002] In modern information technology systems, network isolation is a crucial security measure widely used in enterprise-level network architectures, especially in large organizations and the operation of critical infrastructure. Network isolation strategies use physical or logical means to divide network areas into different levels, such as low-level and high-level network segments. High-level network segments can access low-level network segments, but low-level network segments cannot directly access high-level network segments, thereby limiting the scope and direction of data flow and enhancing the security of core assets. While this isolation strategy protects the resources of high-level network segments from potential threats from external sources or low-level network segments, it also presents challenges to data sharing and communication efficiency.
[0003] Communication between lower-level and higher-level network segments is restricted by strict access controls, resulting in complex and inefficient data exchange processes. In related technologies, especially when handling a large number of concurrent requests and priority-sensitive communication scenarios, RabbitMQ message queues are used as an intermediary. However, due to RabbitMQ's first-in-first-out (FIFO) consumption mechanism, this communication method is prone to queue message blocking. This causes some real-time communication data to be blocked by less real-time communication data, resulting in low business processing efficiency and poor communication reliability. Furthermore, the mixed processing of critical business messages and ordinary messages leads to delays in high-priority messages, affecting normal business processing.
[0004] There is currently no effective solution to the above problems. Summary of the Invention
[0005] This invention provides a cross-network segment communication method, apparatus, electronic device, and storage medium to at least solve the technical problems in related technologies where cross-network segment communication using RabbitMQ as an intermediary is prone to queue message blocking due to RabbitMQ's first-in-first-out sequential consumption mechanism, resulting in low business processing efficiency and poor communication reliability.
[0006] According to one aspect of the present invention, a cross-network segment communication method is provided, comprising: receiving a target request message sent by a producer in a first type of network segment, and distributing the target request message to a target fragment queue of an adapter in the first type of network segment, wherein the adapter contains N fragment queues, where N is a positive integer, and each fragment queue is divided into a first-level fragment queue, a second-level fragment queue, and a third-level fragment queue according to priority, wherein the priority of the first-level fragment queue is lower than that of the second-level fragment queue, and the priority of the second-level fragment queue is lower than that of the third-level fragment queue; a consumer consumes request messages from the fragment queues according to priority; determining a second type of network segment to be accessed based on the target request message, and querying a routing table based on the network segment identifier of the first type of network segment and the network segment identifier of the second type of network segment to obtain a first communication path and a second communication path between the first type of network segment and the second type of network segment. The communication path has a lower security level than the second type of network segment, and a higher communication priority than the second communication path. When the communication status of the first communication path is reachable, the first proxy center of the second type of network segment is controlled to listen for and receive target request messages in the target shard queue. Alternatively, when the communication status of the first communication path is unreachable, the second proxy center of the network partition is controlled to listen for target request messages in the target shard queue. The first proxy center and the second proxy center are subordinate to each other. The producer receives response data returned by either the first or second proxy center and stores the response data in the cache middleware of the first type of network segment. The producer reads the response data corresponding to the target request message from the cache middleware through a polling method.
[0007] Further, the step of distributing the target request message to the target fragment queue of the adapter in the first type of network segment includes: parsing the request message to obtain message attributes; calculating a hash value based on the message attributes, and determining the fragment queue to be distributed based on the hash value; obtaining the priority of the request message, and determining the target fragment queue based on the fragment queue to be distributed and the priority; and distributing the target request message to the target fragment queue.
[0008] Furthermore, before receiving the target request message sent by the producer in the first type of network segment, the method further includes: obtaining all communication network segments and performing route registration on the communication network segments, wherein the communication network segments are divided into first type network segments and second type network segments based on the security level; performing path planning between the first type network segments and the second type network segments to generate communication paths between each first type network segment and each second type network segment, wherein the communication paths include at least: the first communication path and the second communication path; and creating the routing table based on the first type network segments, the second type network segments, and the communication paths between the first type network segments and the second type network segments.
[0009] Further, when the communication status of the first communication path is reachable, the step of controlling the first proxy center of the second type of network segment to listen to and receive the target request message in the target shard queue includes: obtaining the initial communication status of the first communication path, wherein the initial communication status is reachable; when the first communication path is reachable, controlling the first proxy center of the second type of network segment to listen to the shard queue of the adapter until the target request message in the target shard queue is detected, and receiving the target request message, wherein after receiving the target request message, the first proxy center determines the target to be accessed based on the request target field of the target request message, and accesses the target to be accessed using the access strategy corresponding to the target to be accessed, and receives the response data returned by the target to be accessed; storing the response data returned by the first proxy center in the cache middleware of the first type of network segment.
[0010] Furthermore, after storing the response data returned by the first proxy center in the caching middleware of the first type of network segment, the method further includes: if the first proxy center fails to store the response data, determining that there is a communication failure in the first communication path, storing the response data in the message queue of the first proxy center; controlling the second proxy center to listen to the response data in the message queue of the first proxy center, and if the response data corresponding to the target request message is detected, obtaining the response data corresponding to the target request message and storing the response data in the caching middleware.
[0011] Further, when the communication status of the first communication path is unreachable, the step of controlling the second proxy center of the network partition to listen to the target request message of the target shard queue includes: when the first proxy center of the second type of network segment fails to listen to the shard queue of the adapter, determining that the first communication path has a communication failure, and updating the communication status of the first communication path with the communication failure to an unreachable state; when the communication status of the first communication path is unreachable, switching to the second communication path for communication, controlling the second proxy center in the network partition to listen to the shard queue of the adapter until the target request message in the target shard queue is heard, receiving the target request message, wherein, after obtaining the target request message, the second proxy center requests the target to be accessed on behalf of the target based on the request target field of the target request message, and receives the response data returned by the target to be accessed; storing the response data returned by the second proxy center in the caching middleware of the first type of network segment.
[0012] Further, the step of receiving response data returned by the first proxy center or the second proxy center and storing the response data in the caching middleware of the first type of network segment includes: receiving response data returned by the first proxy center or the second proxy center; storing the identification information of the target request message and the response data in the form of key-value pairs in the caching middleware of the first type of network segment; configuring an expiration time for the response data stored in the caching middleware; and clearing the response data from the caching middleware when the expiration time is reached.
[0013] According to another aspect of the present invention, a cross-network segment communication device is also provided. A receiving unit is configured to receive a target request message sent by a producer in a first type of network segment and distribute the target request message to a target shard queue of an adapter in the first type of network segment. The adapter contains N shard queues, where N is a positive integer. Each shard queue is divided into a first-level shard queue, a second-level shard queue, and a third-level shard queue according to priority. The first-level shard queue has a lower priority than the second-level shard queue, and the second-level shard queue has a lower priority than the third-level shard queue. Consumers consume request messages from the shard queues according to priority. A query unit is configured to determine a second type of network segment to be accessed based on the target request message, and query a routing table based on the network segment identifiers of the first type of network segment and the second type of network segment to obtain a first communication path and a second communication path between the first type of network segment and the second type of network segment. The system comprises: a control unit, configured to control the first proxy center of the second type of network segment to listen to and receive target request messages in the target shard queue when the communication status of the first communication path is reachable; or, to control the second proxy center of the network partition to listen to target request messages in the target shard queue when the communication status of the first communication path is unreachable, wherein the first proxy center and the second proxy center are subordinate to each other; and a storage unit, configured to receive response data returned by the first proxy center or the second proxy center and store the response data in the cache middleware of the first type of network segment, wherein the producer reads the response data corresponding to the target request message from the cache middleware in a polling manner.
[0014] Further, the receiving unit includes: a first parsing module, used to parse the request message and obtain message attributes; a calculation unit, used to calculate a hash value based on the message attributes and determine a shard queue to be distributed based on the hash value; a determining unit, used to obtain the priority of the request message and determine the target shard queue based on the shard queue to be distributed and the priority; and a distribution unit, used to distribute the target request message to the target shard queue.
[0015] Furthermore, the cross-network segment communication device further includes: a first registration module, configured to acquire all communication network segments and perform route registration on the communication network segments, wherein the communication network segments are divided into first-class network segments and second-class network segments based on the security level; a first generation module, configured to perform path planning between the first-class network segments and the second-class network segments, generating communication paths between each first-class network segment and each second-class network segment, wherein the communication paths include at least: the first communication path and the second communication path; and a first creation module, configured to create the routing table based on the first-class network segments, the second-class network segments, and the communication paths between the first-class network segments and the second-class network segments.
[0016] Further, the control unit includes: a first acquisition module, configured to acquire the initial communication state of the first communication path, wherein the initial communication state is a reachable state; a first control module, configured to, when the first communication path is reachable, control the first proxy center of the second type of network segment to listen to the shard queue of the adapter until the target request message in the target shard queue is detected, and receive the target request message, wherein, after receiving the target request message, the first proxy center determines the target to be accessed based on the request target field of the target request message, and accesses the target to be accessed using the access strategy corresponding to the target to be accessed, and receives the response data returned by the target to be accessed; and a first storage module, configured to store the response data returned by the first proxy center in the caching middleware of the first type of network segment.
[0017] Furthermore, the control unit further includes: a second storage module, used to determine that there is a communication failure in the first communication path when the first proxy center fails to store the response data, and to store the response data in the message queue of the first proxy center; and a second acquisition module, used to control the second proxy center to listen to the response data in the message queue of the first proxy center, and to acquire the response data corresponding to the target request message and store the response data in the cache middleware when the response data corresponding to the target request message is detected.
[0018] Furthermore, the control unit further includes: a first update module, configured to determine that the first communication path has a communication failure when the first proxy center of the second type of network segment fails to monitor the fragment queue of the adapter, and update the communication status of the first communication path with the communication failure to an unreachable state; a first switching module, configured to switch the second communication path for communication when the communication status of the first communication path is unreachable, and control the second proxy center in the network partition to monitor the fragment queue of the adapter until the target request message in the target fragment queue is detected, and receive the target request message, wherein, after obtaining the target request message, the second proxy center requests the target to be accessed on behalf of the target based on the request target field of the target request message, and receives the response data returned by the target to be accessed; and a fourth storage module, configured to store the response data returned by the second proxy center in the caching middleware of the first type of network segment.
[0019] Furthermore, the storage unit includes: a first receiving module, configured to receive response data returned by the first proxy center or the second proxy center, and store the identification information of the target request message and the response data in the form of key-value pairs in the caching middleware of the first type of network segment; and a first configuration module, configured to configure an expiration time for the response data stored in the caching middleware, and clear the response data from the caching middleware when the expiration time is reached.
[0020] According to another aspect of the present invention, a computer-readable storage medium is also provided, the computer-readable storage medium including a stored computer program, wherein, when the computer program is executed, it controls the device where the computer-readable storage medium is located to perform any of the above-described cross-network segment communication methods.
[0021] According to another aspect of the present invention, an electronic device is also provided, including one or more processors and a memory, the memory being used to store one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors cause the one or more processors to implement any of the above-described cross-network segment communication methods.
[0022] In this application, the following steps are used: receiving a target request message sent by a producer in a first-class network segment, and distributing the target request message to the target fragment queue of the adapter in the first-class network segment. The adapter contains N fragment queues, where N is a positive integer. Each fragment queue is divided into a first-level fragment queue, a second-level fragment queue, and a third-level fragment queue according to priority. The first-level fragment queue has a lower priority than the second-level fragment queue, and the second-level fragment queue has a lower priority than the third-level fragment queue. Consumers consume request messages from fragment queues according to priority. Then, based on the target request message, the second-class network segment to be accessed is determined, and the routing table is queried based on the network segment identifiers of the first-class and second-class network segments to obtain the first and second communication paths between the first and second-class network segments. The security level of the first type of network segment is lower than that of the second type of network segment, and the communication priority of the first communication path is higher than that of the second communication path. When the communication status of the first communication path is reachable, the first proxy center of the second type of network segment is controlled to listen for and receive target request messages in the target fragment queue. Alternatively, when the communication status of the first communication path is unreachable, the second proxy center of the network partition is controlled to listen for target request messages in the target fragment queue. The first proxy center and the second proxy center are subordinate to each other. Finally, the response data returned by the first proxy center or the second proxy center is received, and the response data is stored in the cache middleware of the first type of network segment. The producer reads the response data corresponding to the target request message from the cache middleware in a round-robin manner.
[0023] In this application, an intelligent routing mechanism is employed, combined with a proxy center consuming messages pre-distributed to sharded queues. The proxy center is divided into a primary proxy center and subordinate proxy centers, providing multiple communication paths. If one communication path fails, another can be quickly switched, effectively avoiding communication interruptions caused by single points of failure and improving communication reliability and stability. Furthermore, priority sharding and queue design ensure that high-priority business messages are processed and responded to more quickly, improving the system's real-time response capability and business processing efficiency, while also increasing system throughput. This supports data exchange in large-scale, high-concurrency scenarios and reduces message blocking issues. This addresses the technical problems in related technologies where RabbitMQ is used as an intermediary for cross-network segment communication. Due to RabbitMQ's first-in-first-out (FIFO) sequential consumption mechanism, queue message blocking is easily caused, resulting in low business processing efficiency and poor communication reliability. Attached Figure Description
[0024] The accompanying drawings, which are included to provide a further understanding of the invention and form part of this application, illustrate exemplary embodiments of the invention and, together with their description, serve to explain the invention and do not constitute an undue limitation thereof. In the drawings:
[0025] Figure 1 This is a flowchart of an optional cross-network segment communication method according to an embodiment of the present invention;
[0026] Figure 2 This is an architecture diagram of an optional cross-network segment communication system according to an embodiment of the present invention;
[0027] Figure 3 This is a schematic diagram of an optional cross-segment communication device according to an embodiment of the present invention;
[0028] Figure 4 This is a hardware structure block diagram of an electronic device (or mobile device) that performs a cross-network segment communication method according to an embodiment of the present invention. Detailed Implementation
[0029] To enable those skilled in the art to better understand the present invention, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort should fall within the scope of protection of the present invention.
[0030] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this invention are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of the invention described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover a non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.
[0031] To facilitate understanding of the present invention by those skilled in the art, some terms or nouns involved in the various embodiments of the present invention are explained below:
[0032] RabbitMQ is an open-source message queue middleware.
[0033] Redis is a caching middleware based on key-value pair storage.
[0034] It should be noted that the cross-network segment communication method and apparatus in this application can be used in the field of communication technology for cross-network segment communication, and can also be used in any field other than the field of communication technology for cross-network segment communication. This application does not limit the application field of the cross-network segment communication method and apparatus.
[0035] It should be noted that the relevant information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, and displayed data) involved in this application are information and data authorized by the user or fully authorized by all parties. Furthermore, the collection, storage, use, processing, transmission, provision, disclosure, and application of this data all comply with the relevant laws, regulations, and standards of the relevant regions, have taken necessary confidentiality measures, do not violate public order and good morals, and provide corresponding access points for users to choose to authorize or refuse. For example, this system has an interface with relevant users or organizations. Before obtaining relevant information, a request to obtain the information needs to be sent to the aforementioned user or organization through the interface, and the relevant information is obtained only after receiving consent from the aforementioned user or organization.
[0036] It should be noted that in this application, when collecting and analyzing customer information, users are provided with corresponding operation entry points to choose whether to agree to or reject the automated decision-making results; if the user chooses to reject, the process will proceed to the expert decision-making process.
[0037] The following embodiments of the present invention can be applied to various cross-network segment communication systems / applications / devices. The present invention enables communication between lower-level and higher-level network segments through a control center and a proxy center, improves communication reliability through dynamic routing configuration, and enhances service throughput and processing efficiency through priority fragmentation and queue design, thus ensuring critical services are protected.
[0038] The present invention will now be described in detail with reference to various embodiments.
[0039] Example 1
[0040] According to an embodiment of the present invention, an embodiment of a cross-network segment communication method is provided. It should be noted that the steps shown in the flowchart in the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions. Furthermore, although a logical order is shown in the flowchart, in some cases, the steps shown or described may be executed in a different order than that shown here.
[0041] Figure 1 This is a flowchart of an optional cross-network segment communication method according to an embodiment of the present invention, such as... Figure 1 As shown, the method includes the following steps:
[0042] It should be noted that the implementation subject of this embodiment is a cross-network segment communication system. The cross-network segment communication system consumes messages from the fragmented queue through the control center, ensuring, for example, decoupled communication between low-level network segments and high-level network segments.
[0043] In an optional embodiment, before receiving the target request message sent by the producer in the first type of network segment, the method further includes: obtaining all communication network segments and registering routes for the communication network segments, wherein the communication network segments are divided into first type network segments and second type network segments based on security levels; performing path planning between the first type network segments and the second type network segments to generate communication paths between each first type network segment and each second type network segment, wherein the communication paths include at least: a first communication path and a second communication path; and creating a routing table based on the first type network segments, the second type network segments, and the communication paths between the first type network segments and the second type network segments.
[0044] It should be noted that the embodiments of the present invention pre-configure and plan a dynamic routing mechanism to achieve decoupled communication between network segments of different levels. Specifically, firstly, information on all network segments participating in communication in the entire network architecture is obtained, and the communication network segments are registered. The registered communication network segments are divided into Class 1 network segments (low-level network segments) and Class 2 network segments (high-level network segments) according to a pre-set security level. That is, Class 1 network segments have the highest priority, while Class 2 network segments have the lowest. According to the isolation mechanism, Class 1 network segments cannot directly access Class 2 network segments, resulting in certain communication restrictions. To enable Class 1 network segments to access Class 2 network segments, detailed path planning is required for the communication relationship between each Class 1 and Class 2 network segment. During the planning process, at least two communication paths are created: a high-priority first communication path, serving as the primary communication path for data transmission under normal circumstances; and a backup second communication path, serving as a redundancy option in case the first path fails, to maintain the continuity of data communication. The planning of each path comprehensively considers factors such as network bandwidth, latency, security, and load balancing to ensure optimal path selection.
[0045] Finally, based on the results of the above path planning, a detailed routing table is created, recording the communication path information between all Class I and Class II network segments. The routing table not only includes the network identifier of each network segment but also details the status (e.g., reachable or unreachable), priority, and related control commands for each path, specifying when to activate the first communication path and when to switch to the second communication path. The routing table plays a central role in subsequent communication control and is the core basis for dynamic routing decisions.
[0046] Through the above steps, comprehensive planning and efficient management of communication paths in the network architecture are achieved, ensuring that the most suitable communication path can be quickly located at any time, regardless of changes in network conditions. The high-priority first communication path guarantees the rapid transmission of critical business data, reduces latency, and improves overall communication efficiency. The existence of the second communication path enables the system to automatically bypass faulty nodes, maintaining uninterrupted communication and significantly improving the stability and fault tolerance of network communication.
[0047] Step S101: Receive the target request message sent by the producer in the first type of network segment, and distribute the target request message to the target fragment queue of the adapter in the first type of network segment.
[0048] In step S101 above, the receiving endpoint deployed in the first-class network segment (low-level network segment) listens for requests from producers in real time. Producers can be any application or service that needs to communicate with the high-security second-class network segment (high-level network segment). When a producer in the low-level network segment needs to access resources in the high-level network segment, it encapsulates the request information into a unified format, such as JSON. The request message includes key fields such as requestId (request identifier), requestTime (request time), and requestTarget (request target) to ensure message format consistency and facilitate subsequent processing.
[0049] The control center distributes received request messages to the adapter's sharding queues using an intelligent distribution strategy. The adapter employs N logical sharding queues, where N is a positive integer representing the number of queues that can be dynamically adjusted based on network load and business needs. Each sharding queue is further divided into three priority queues: the priority of the first-level sharding queue is lower than that of the second-level sharding queue, and the priority of the second-level sharding queue is lower than that of the third-level sharding queue. This priority division ensures that critical business messages are processed first, preventing them from being blocked by a large number of low-priority messages. Based on the "priority" field in the request message sent by the producer, the adapter algorithm allocates the message to the sharding queue of the corresponding priority. For example, high-priority messages are placed in the third-level sharding queue, medium-priority messages in the second-level sharding queue, and low-priority messages in the first-level sharding queue.
[0050] Consumers deployed in the second-class network segment (typically the proxy center of the second-class network segment) follow a priority consumption principle, processing messages in high-priority queues first. This means that even with a large influx of low-priority messages, critical business requests can still be responded to promptly. Consumers continuously monitor each shard queue, consuming new request messages according to their priority when they appear in the queue. This mechanism ensures the immediate processing of high-priority messages while also accommodating the final processing of low-priority messages.
[0051] Furthermore, the steps of distributing the target request message to the target fragment queue of the adapter in the first type of network segment include: parsing the request message to obtain message attributes; calculating a hash value based on the message attributes and determining the fragment queue to be distributed based on the hash value; obtaining the priority of the request message and determining the target fragment queue based on the fragment queue to be distributed and the priority; and distributing the target request message to the target fragment queue.
[0052] Specifically, after receiving a target request message, the adapter first parses it to extract message attributes such as requestId, requestTarget, networkZone, and priority. This information is used for subsequent hash calculations and priority evaluation. Based on the extracted message attributes, a hash value is calculated using a hash algorithm (such as MD5, SHA-256, etc.). This hash value determines which specific shard queue the message should be stored in. The calculated hash value is compared with the sharding rules of N shard queues in the adapter to determine the most suitable shard queue for storing the message. There is a mapping relationship between the hash value and the queue selection, ensuring that messages are evenly distributed across shard queues, avoiding the formation of hot queues, thereby improving overall processing capacity and efficiency. After determining the shard queue to be distributed to, the shard queue to be distributed is divided into multi-level shard queues according to priority. Then, the request priority is read from the parsed message attributes to further determine which priority level queue the message should enter, thus determining the target shard queue, and distributing the target request message to the target shard queue.
[0053] Step S102: Determine the second type of network segment to be accessed based on the target request message, and query the routing table based on the network segment identifier of the first type of network segment and the network segment identifier of the second type of network segment to obtain the first communication path and the second communication path between the first type of network segment and the second type of network segment.
[0054] In step S102 above, the adapter parses the target request message and extracts the network segment identifier of the target system or service, i.e., the network segment identifier of the second type of network segment. Combined with the network segment identifier of the first type of network segment from the source of the request message, a query key value is constructed. Then, the adapter queries the pre-created routing table according to the query key value to obtain the communication path between the first type of network segment and the second type of network segment. Specifically, it includes the first communication path and the second communication path. The communication priority of the first communication path is higher than that of the second communication path. If the first communication path is available, the first type of communication path is used for communication by default. During message transmission, the adapter continuously monitors the path status. When a failure is detected in the first communication path, the adapter will immediately update the status of the path in the routing table to "unreachable" and automatically route subsequent messages to the second communication path.
[0055] Step S103: If the communication status of the first communication path is reachable, control the first proxy center of the second type of network segment to listen to and receive target request messages in the target fragment queue; or, if the communication status of the first communication path is unreachable, control the second proxy center of the network partition to listen to target request messages in the target fragment queue.
[0056] In step S103 above, the system selects different proxy centers for message listening and receiving based on the communication status (reachable or unreachable) of the first communication path, ensuring that communication services are not interrupted even in the event of a network failure, thereby guaranteeing the high reliability and business continuity of the system. The proxy centers are divided into a first proxy center deployed in the second type of network segment and a second proxy center deployed in the network partition; the first and second proxy centers are subordinate to each other. The first communication path is implemented based on the first proxy center, and the second communication path is implemented based on the second proxy center.
[0057] The adapter first queries the routing table to confirm that the current status of the first communication path is "reachable." This typically means that the direct communication path from the first-class network segment to the second-class network segment is valid and there are no network failures or security restrictions. With the first communication path "reachable," the adapter controls the first proxy center in the second-class network segment to begin listening for target request messages in the target fragment queue. Upon receiving a target request message, the first proxy center will unpack the message, execute business logic, interact with the target service, and ultimately generate a response message according to a predetermined processing flow.
[0058] When the adapter detects that the first communication path has become "unreachable," it immediately initiates a failover mechanism. Unreachability can be caused by network failures, middleware failures, security policy changes, or other reasons. In the event of a first communication path failure, the adapter selects a second proxy center (usually a slave proxy center) within the network partition as the new message receiver based on information in the routing table. The adapter sends control commands to the second proxy center, instructing it to begin listening for target request messages in the target fragment queue, preparing to receive and process these messages that are currently in the queue. Upon receiving the target request message, the second proxy center performs the same business processing flow as the first proxy center, generates a response message, and sends the response message back to the producer of the first-class network segment via the updated communication path.
[0059] In one optional embodiment, after the adapter transforms the request message through the first communication path, it can determine whether the first communication path is reachable by periodically listening to the response message of the cached middleware in the first type of network segment. If no response message is received from the second proxy center within a preset time period, the first communication path is determined to be unreachable, and the status information of the first communication path is updated in the routing table.
[0060] Further, when the communication status of the first communication path is reachable, the step of controlling the first proxy center of the second type of network segment to listen to and receive target request messages in the target fragment queue includes: obtaining the initial communication status of the first communication path, wherein the initial communication status is reachable; when the first communication path is reachable, controlling the first proxy center of the second type of network segment to listen to the fragment queue of the adapter until a target request message is heard in the target fragment queue, receiving the target request message, wherein after receiving the target request message, the first proxy center determines the target to be accessed based on the request target field of the target request message, and accesses the target to be accessed using the access strategy corresponding to the target to be accessed, and receives the response data returned by the target to be accessed; storing the response data returned by the first proxy center in the cache middleware of the first type of network segment.
[0061] Specifically, since the first communication path has higher priority than the second communication path, communication is initiated based on the first communication path. The initial state of the first communication path is set to reachable by default. The adapter sends a control command to the first proxy center in the second-class network segment to start listening to the shard queue. The first proxy center continuously listens to the target shard queue until it receives a target request message. Upon receiving the request message, it parses it according to its structure and content, especially the "request target" field, to determine the target service or system to be accessed. Based on the identified target service or system, the first proxy center uses a predefined access strategy to access the target, including but not limited to authentication, encryption, and data format conversion. After the target successfully executes its business logic, the first proxy center receives response data from the target system. The response data contains key information such as the result of the business processing and status information. The first proxy center writes the received response data, along with the requestId from the target request message, into a key-value pair in the cache middleware of the first-class network segment, such as Redis. This ensures that producers in lower-level network segments can obtain the response results in a timely manner.
[0062] In one optional embodiment, when processing requests, the first agent center prioritizes messages in high-priority queues to ensure timely response to critical business operations.
[0063] Furthermore, after storing the response data returned by the first proxy center in the caching middleware of the first type of network segment, the method further includes: if the first proxy center fails to store the response data, storing the response data in the message queue of the first proxy center; controlling the second proxy center to listen to the response data in the message queue of the first proxy center, and if the response data corresponding to the target request message is detected, obtaining the response data corresponding to the target request message and storing the response data in the caching middleware.
[0064] Specifically, if the first proxy center fails to store the response data in the caching middleware of the first type of network segment, it assumes a communication failure on the first communication path and stores the response data in its own RabbitMQ message queue (the first proxy center's message queue). This ensures that the response data is not lost due to the communication failure, and it requests the adapter to update the communication status of the first communication path in the routing table to unreachable. Simultaneously, it switches to the second communication path for communication, controlling the second proxy center to listen for response data in the first proxy center's message queue. Once the second proxy center detects the response data corresponding to the target request message, it stores it in the caching middleware of the first type of network segment, ensuring that the producer can obtain the response data.
[0065] Furthermore, when the communication status of the first communication path is unreachable, the step of the second agent center controlling the network partition to listen to the target request message of the target fragment queue includes: when the first agent center controlling the second type of network segment fails to listen to the fragment queue of the adapter, it is determined that there is a communication failure in the first communication path, and the communication status of the first communication path with communication failure is updated to unreachable; when the communication status of the first communication path is unreachable, the second communication path is switched to communicate, and the second agent center in the network partition listens to the fragment queue of the adapter until a target request message in the target fragment queue is heard, and the target request message is received. Among them, after obtaining the target request message, the second agent center requests the target to be accessed on behalf of the target based on the request target field of the target request message, and receives the response data returned by the target to be accessed; the response data returned by the second agent center is stored in the caching middleware of the first type of network segment.
[0066] In an optional embodiment, after storing the response data returned by the first proxy center in the cache middleware of the first type of network segment, the method further includes: reading the response data corresponding to the target request message from the cache middleware through the adapter of the first type of network segment; if the response data reading fails within a preset time period, it can be determined that the first proxy center of the second type of network segment has failed to listen to the fragment queue of the adapter, thereby determining that there is a communication failure in the first communication path.
[0067] Specifically, if a communication failure occurs on the first communication path, the communication status of the first communication path is configured as unreachable in the routing table. Simultaneously, the adapter automatically switches to the second communication path, which typically means that messages will be relayed through the second proxy center. The second proxy center in the request network partition begins listening to the shard queues. The second proxy center also follows queue priorities, listening to shard queues of different priorities sequentially until it receives the target request message. After receiving the target request message, the second proxy center determines the target service or system to be accessed based on the request target field and uses the appropriate access strategy to request the target and complete the business logic processing. Simultaneously, it receives response data from the target service or system and stores it in the caching middleware of the first-class network segment for producers to quickly obtain the response results.
[0068] By configuring the second proxy center, even if the first communication path fails, it can be ensured that the response data can eventually reach the first-class network segment, maintaining the continuity of communication services and the accessibility of data.
[0069] Step S104: Receive response data returned by the first proxy center or the second proxy center, and store the response data in the cache middleware of the first type of network segment.
[0070] In step S104 above, both the first and second proxy centers, after completing the business processing of the target request message and interacting with the third-party system, will generate response data and prepare to send it back to the network segment where the producer resides. The system receives the response data returned from the first or second proxy center. After receiving the response data, the system parses the response data to ensure that its format and content meet the requirements of the caching middleware. Parsing includes, but is not limited to, converting the response data into a cache-suitable format, such as JSON, and attaching necessary metadata. The parsed response data, along with the requestId from the target request message, is written to the caching middleware of the first type of network segment in key-value format. The response data stored in the caching middleware will be read by the producer through a polling method.
[0071] Furthermore, the step of receiving response data returned by the first proxy center or the second proxy center and storing the response data in the caching middleware of the first type of network segment includes: receiving response data returned by the first proxy center or the second proxy center, storing the identification information of the target request message and the response data in the form of key-value pairs in the caching middleware of the first type of network segment; configuring an expiration time for the response data stored in the caching middleware, and clearing the response data from the caching middleware when the expiration time is reached.
[0072] Specifically, when storing response data, to ensure that the producer can accurately read the response data required by the slave machine, the system encapsulates the identifier information (requestId) in the target request message as the key and the response data as the value, storing them as key-value pairs. Simultaneously, to ensure the efficient operation of the caching middleware and prevent expired data from consuming resources, an expiration time needs to be configured for the response data stored in the caching middleware. When the response data reaches the set expiration time, the caching middleware automatically removes it from the cache, releasing the occupied resources. This mechanism ensures the dynamism of the caching middleware and the efficient use of space, while also preventing information inconsistencies caused by data expiration.
[0073] Furthermore, after sending a request, the producer in the lower-level network segment will use the requestId as the query key and poll the cache middleware at regular intervals (e.g., 100 milliseconds) to check if the corresponding response data exists. If the producer successfully retrieves the response data during the polling process, it will parse the response body, determine whether the request was successful based on the httpStatus field, and proceed with subsequent business processing. If the response data is not retrieved after 1 minute (i.e., the cache expiration time), the producer will report a timeout exception. At this point, it may be necessary to re-initiate the request or take other fault recovery measures.
[0074] Through the above steps, the system receives target request messages sent by producers in the first type of network segment and distributes these messages to target fragment queues in the adapter of the first type of network segment. Each adapter contains N fragment queues, where N is a positive integer. Each fragment queue is divided into primary, secondary, and tertiary fragment queues according to priority. The primary fragment queue has a lower priority than the secondary fragment queue, and the secondary fragment queue has a lower priority than the tertiary fragment queue. Consumers consume request messages from fragment queues according to priority. Then, based on the target request message, the system determines the second type of network segment to be accessed and queries the routing table based on the network segment identifiers of the first and second types of network segments to obtain the first and second communication paths between the first and second types of network segments. The security level of the first type of network segment is lower than that of the second type of network segment, and the communication priority of the first communication path is higher than that of the second communication path. When the communication status of the first communication path is reachable, the first proxy center of the second type of network segment is controlled to listen for and receive target request messages in the target fragment queue. Alternatively, when the communication status of the first communication path is unreachable, the second proxy center of the network partition is controlled to listen for target request messages in the target fragment queue. The first and second proxy centers are subordinate to each other. Finally, the response data returned by the first or second proxy center is received and stored in the cache middleware of the first type of network segment. The producer reads the response data corresponding to the target request message from the cache middleware in a polling manner.
[0075] In this embodiment, an intelligent routing mechanism is used, combined with a proxy center consuming messages pre-distributed to sharded queues. The proxy center is divided into a primary proxy center and subordinate proxy centers, providing multiple communication paths. If one communication path fails, another communication path can be quickly switched, effectively avoiding communication interruptions caused by single points of failure and improving communication reliability and stability. In addition, priority sharding and queue design ensure that high-priority business messages are processed and responded to faster, improving the system's real-time response capability and business processing efficiency, while also increasing system throughput, supporting data exchange in large-scale high-concurrency scenarios, and reducing message blocking problems. This solves the technical problems in related technologies where RabbitMQ is used as an intermediary for cross-network segment communication, where the RabbitMQ first-in-first-out sequential consumption mechanism easily leads to queue message blocking, resulting in low business processing efficiency and poor communication reliability.
[0076] The following describes in detail another optional implementation method.
[0077] Figure 2 This is an architecture diagram of an optional cross-network segment communication system according to an embodiment of the present invention, such as... Figure 2As shown, the cross-network segment communication system covers communication between low-level network segments (corresponding to the first type of network segments mentioned above) and high-level network segments (corresponding to the second type of network segments mentioned above). Producers in the low-level network segment send request messages to the control center to initiate service processing requests. The control center includes a routing registration module and adapters. The routing registration module records node communication paths and dynamically provides paths to the adapters. Regardless of whether it is a high-level network segment IP or a low-level network segment IP, by registering routing information in the routing table, the planning and sorting of each path from a high-level network segment IP to a low-level network segment IP is realized. The routing table uses status indicators to indicate whether the path is reachable or unreachable.
[0078] The adapter implements logical sharded queues and priority queues based on RabbitMQ. This ensures decoupling between lower-level and higher-level network segments, resolves bottlenecks in sequential processing, and guarantees the priority of critical business operations. When a network communication failure occurs between the higher-level and lower-level network segments, subsequent requests are automatically routed to an alternative communication path. This alternative path then requests third-party systems on behalf of the requester to complete message communication and updates the relevant path status in the routing table.
[0079] Agent centers are deployed in both the high-level network segment and the network partition. The high-level network segment deploys the agent center master (corresponding to the first agent center mentioned above), and the network partition deploys the agent center slave (corresponding to the second agent center mentioned above). The agent center master can directly access the adapter and communicate with the low-level network segment through the first communication path. If the first communication path fails, it switches to the second communication path, and the agent center slave communicates with the low-level network segment, acting as a proxy to request third-party systems (i.e., the target system / service requested by the producer) to process related business.
[0080] The broker module consists of two components: RabbitMQ and a consumer component. The consumer component is responsible for consuming messages, requesting third-party systems in the higher-level network segment, and writing the response data, along with the unique identifier (requestId) carried in the request message, into a cache middleware (such as Redis) in key-value format. When communication between the higher-level and lower-level network segments encounters timeouts or disconnections, the returned data is stored in its own RabbitMQ, which is then monitored and retrieved by the broker slave, and subsequently stored in the cache middleware.
[0081] The response data returned by the master and slave proxy centers are stored in key-value pairs in the storage middleware of the lower network segment, namely Redis. The expiration time of the data stored in the caching middleware is set to 1 minute (or other values, this is just an example) to ensure that the response data can be queried by the producer within a certain period of time.
[0082] After sending a request message, the producer in the lower-level network segment immediately uses the generated requestId as the query key to poll the cache middleware every 100 milliseconds (or other values, this is just an example). If a result is found, the response body is parsed and subsequent business processing continues; if no result is found after 1 minute, a timeout exception is reported. In this way, the producer can obtain a real-time response similar to synchronous access on the basis of asynchronous access.
[0083] This transmission embodiment uses a unified format to encapsulate request messages and response data, such as JSON. Request messages include fields such as requestId (request identifier), requestTime (request time), requestTarget (request target, used to identify the target system or service of this request), url (request address), method (request method), headers (request headers), and params (request parameters, containing parameters required to call the API). Response messages include fields such as requestId, httpStatus (response status), requestTarget, responseTime (response time), and data (response parameters). This unified format and protocol ensures consistency and scalability of data interaction between different components.
[0084] The communication process between lower-level network segments and higher-level network segments specifically includes:
[0085] Step one: When a producer in a lower-level network segment needs to access resources in a higher-level network segment, it first encapsulates the request message into a unified JSON format and sends the request message to the control center. The request message includes the following fields:
[0086] requestId: A unique identifier for the request, facilitating subsequent traceability.
[0087] requestTime: Request time, records the timestamp when the request was initiated.
[0088] requestTarget: The target of this request, used to identify the target system or service.
[0089] url: The request address, specifying the API interface address of the target system.
[0090] method: Request method, such as GET, POST, etc.
[0091] headers: Request headers contain necessary authentication information or other metadata.
[0092] params: Request parameters, which contain the parameters required to call the API.
[0093] networkZone: A network partition used to identify the network segment to which a message is sent.
[0094] priority: Priority, specifies the message level.
[0095] Step two: The encapsulated request message is sent to the control center adapter component deployed on the same network segment. The adapter component consists of logical sharded queues and priority queues. First, a logical sharded queue design is implemented based on the RabbitMQ queue: the original single RabbitMQ queue is split into multiple logical sharded queues (e.g., queue_partition_num_0, queue_partition_num_1, queue_partition_num_2, ..., queue_partition_num_N). A hash value is calculated based on message attributes (e.g., requestId) using a hash algorithm, and the message is distributed to different sharded queues. Each sharded queue is defined with three levels: high, medium, and low (e.g., priority_high, priority_medium, priority_low). Producers request messages based on the importance of the business and message attributes, such as defining low priority for ordinary business and high priority for critical business. The adapter stores request messages of different priorities in different priority queues within the sharded queues. When consuming data, consumers will prioritize consuming messages with higher priority.
[0096] The adapter determines the low-level and high-level network segments to be communicated with based on the request message, and obtains the default reachable path registered in the routing table (corresponding to the first communication path mentioned above, such as: high-level network segment IP -> low-level network segment IP, status: reachable). When the default reachable path cannot communicate due to network problems between network segments, the adapter will actively obtain the backup reachable path registered in the routing table (corresponding to the second communication path mentioned above, such as: high-level network segment IP -> proxy center slave IP -> low-level network segment IP, status: reachable). Then, the adapter will transfer the message sent by the producer to the proxy center slave (the proxy center slave listens for and receives messages in the corresponding queue), and the proxy center slave consumer component will consume the message and request the third-party system on its behalf.
[0097] If the first communication path is reachable, the master proxy center in the higher-level network segment listens for and consumes request messages from the message queue. Based on the `requestTarget` field in the request message, the consumer executes an HTTP request to access the corresponding system's API interface using different request strategies, and performs corresponding encryption and authentication logic according to the API interface verification method of the third-party system. For example, if the request target is system A, the executor A-RequestInvoker will be used to execute the request; if the request target is system B, the executor B-RequestInvoker will be used. After the request is completed, the response data is returned.
[0098] If the master proxy center in the higher network segment fails to store response data to Redis, it considers the path (e.g., higher network segment IP -> lower network segment IP) to have a communication failure. It then stores the response data in its own RabbitMQ and updates the routing table status of the lower network segment control center (e.g., higher network segment IP -> lower network segment IP, status: unreachable). Simultaneously, it also stores subsequent response data in its own RabbitMQ, which is then monitored and retrieved by the slave proxy center and stored in Redis.
[0099] If the master proxy in the higher-level network segment fails to listen to the adapter, resulting in the adapter also being unable to retrieve the corresponding response data from Redis, the adapter will consider the communication path (e.g., higher-level network segment IP -> lower-level network segment IP) to have a communication failure and update the routing table path status of the lower-level network segment control center (e.g., higher-level network segment IP -> lower-level network segment IP, status: unreachable). Simultaneously, it will obtain an alternative reachable path (e.g., higher-level network segment IP -> proxy slave IP -> lower-level network segment IP, status: reachable). Subsequent producer requests will then be listened to and retrieved by the proxy slave. The proxy slave, deployed in the highest-level network segment (with a security level equal to or higher than the higher-level network segment), can access both the lower-level and higher-level network segments, request third-party systems on behalf of the proxy slave, retrieve response data, and store the response data in Redis on the lower-level network segment.
[0100] After receiving the response data, the response data, along with the requestId carried in the request message, is written to a caching middleware (such as Redis) in key-value format. The key in the caching middleware is the requestId, and the value is the JSON format of the response data. The expiration time of the caching middleware is set to 1 minute to ensure that the response data can be retrieved by the producer within a certain period of time and that the resources occupied can be released promptly after use.
[0101] For unreachable paths, the adapter periodically retrieves the unreachable paths from the routing table, generates self-test messages to check network connectivity, and automatically updates the status of the relevant paths in the routing table when it receives the self-test return data.
[0102] After sending a request message, the producer in the lower-level network segment immediately polls the cache middleware using the generated requestId as the query key. The producer queries the cache middleware every 100 milliseconds to check if response data corresponding to the requestId exists. If a result is found, the response body is parsed and subsequent business processing continues; if no result is found after 3 minutes, a timeout exception is reported.
[0103] When parsing the response data, the producer uses the `httpStatus` field in the response message to determine if the request was successful. If `httpStatus` is 200 (which can be set according to actual needs), it indicates that the request was successful, and the producer continues to process the business logic in the response data. If `httpStatus` is any other value, it indicates that the request failed, and the producer takes appropriate action based on the error message, such as requesting manual intervention.
[0104] This invention enables communication between low-level and high-level network segments through a control center and a proxy center, improves communication reliability by configuring dynamic routing, and enhances service throughput and processing efficiency through priority sharding and queue design, thus ensuring critical services.
[0105] The following is a detailed description with reference to another embodiment.
[0106] Example 2
[0107] The cross-network segment communication device provided in this embodiment includes multiple implementation units, each of which corresponds to a specific implementation step in the above embodiment one. The specific implementation method and beneficial effects can be referred to the foregoing method embodiment, and will not be repeated here.
[0108] Figure 3 This is a schematic diagram of an optional cross-network segment communication device according to an embodiment of the present invention, such as... Figure 3 As shown, the cross-network segment communication device includes: a receiving unit 31, a query unit 32, a control unit 33, and a storage unit 34, wherein,
[0109] The receiving unit 31 is used to receive target request messages sent by producers in the first type of network segment and distribute the target request messages to the target fragment queues of the adapter in the first type of network segment. The adapter contains N fragment queues, where N is a positive integer. Each fragment queue is divided into a first-level fragment queue, a second-level fragment queue, and a third-level fragment queue according to priority. The priority of the first-level fragment queue is lower than that of the second-level fragment queue, and the priority of the second-level fragment queue is lower than that of the third-level fragment queue. Consumers consume the request messages of the fragment queues according to priority.
[0110] The query unit 32 is used to determine the second type of network segment to be accessed based on the target request message, and query the routing table based on the network segment identifier of the first type of network segment and the network segment identifier of the second type of network segment to obtain the first communication path and the second communication path between the first type of network segment and the second type of network segment, wherein the security level of the first type of network segment is lower than that of the second type of network segment, and the communication priority of the first communication path is higher than that of the second communication path.
[0111] The control unit 33 is configured to control the first agent center of the second type of network segment to listen to and receive target request messages in the target fragment queue when the communication status of the first communication path is reachable; or, when the communication status of the first communication path is unreachable, control the second agent center of the network partition to listen to target request messages in the target fragment queue, wherein the first agent center and the second agent center are subordinate to each other.
[0112] Storage unit 34 is used to receive response data returned by the first proxy center or the second proxy center and store the response data in the cache middleware of the first type of network segment. The producer reads the response data corresponding to the target request message from the cache middleware in a polling manner.
[0113] The aforementioned cross-network segment communication device receives target request messages sent by producers in the first type of network segment through receiving unit 31, and distributes the target request messages to the target fragment queues of the adapter in the first type of network segment. The adapter contains N fragment queues, where N is a positive integer. Each fragment queue is divided into a first-level fragment queue, a second-level fragment queue, and a third-level fragment queue according to priority. The priority of the first-level fragment queue is lower than that of the second-level fragment queue, and the priority of the second-level fragment queue is lower than that of the third-level fragment queue. Consumers consume request messages from fragment queues according to priority. The query unit 32 determines the second type of network segment to be accessed based on the target request message, and queries the routing table based on the network segment identifiers of the first and second types of network segments to obtain the first and second communication paths between the first and second types of network segments. The security level of the first type of network segment is lower than that of the second type of network segment, and the communication priority of the first communication path is higher than that of the second communication path. When the communication status of the first communication path is reachable, the control unit 33 controls the first proxy center of the second type of network segment to listen for and receive target request messages in the target fragment queue. Alternatively, when the communication status of the first communication path is unreachable, the control unit 33 controls the second proxy center of the network partition to listen for target request messages in the target fragment queue. The first proxy center and the second proxy center are subordinate to each other. The storage unit 34 receives the response data returned by the first proxy center or the second proxy center and stores the response data in the cache middleware of the first type of network segment. The producer reads the response data corresponding to the target request message from the cache middleware in a polling manner.
[0114] In this embodiment, an intelligent routing mechanism is used, combined with a proxy center consuming messages pre-distributed to sharded queues. The proxy center is divided into a primary proxy center and subordinate proxy centers, providing multiple communication paths. If one communication path fails, another communication path can be quickly switched, effectively avoiding communication interruptions caused by single points of failure and improving communication reliability and stability. In addition, priority sharding and queue design ensure that high-priority business messages are processed and responded to faster, improving the system's real-time response capability and business processing efficiency, while also increasing system throughput, supporting data exchange in large-scale high-concurrency scenarios, and reducing message blocking problems. This solves the technical problems in related technologies where RabbitMQ is used as an intermediary for cross-network segment communication, where the RabbitMQ first-in-first-out sequential consumption mechanism easily leads to queue message blocking, resulting in low business processing efficiency and poor communication reliability.
[0115] Furthermore, the receiving unit includes: a first parsing module, used to parse the request message and obtain message attributes; a calculation unit, used to calculate a hash value based on the message attributes and determine the shard queue to be distributed based on the hash value; a determination unit, used to obtain the priority of the request message and determine the target shard queue based on the shard queue to be distributed and the priority; and a distribution unit, used to distribute the target request message to the target shard queue.
[0116] Furthermore, the cross-network segment communication device also includes: a first registration module, used to obtain all communication network segments and register routes for the communication network segments, wherein the communication network segments are divided into first-class network segments and second-class network segments based on security levels; a first generation module, used to perform path planning between the first-class network segments and the second-class network segments, generating communication paths between each first-class network segment and each second-class network segment, wherein the communication paths include at least: a first communication path and a second communication path; and a first creation module, used to create a routing table based on the first-class network segments, the second-class network segments, and the communication paths between the first-class network segments and the second-class network segments.
[0117] Further, the control unit includes: a first acquisition module, used to acquire the initial communication state of the first communication path, wherein the initial communication state is a reachable state; a first control module, used to control the first agent center of the second type of network segment to listen to the fragment queue of the adapter until a target request message is heard in the target fragment queue, and receive the target request message, wherein after receiving the target request message, the first agent center determines the target to be accessed based on the request target field of the target request message, and accesses the target to be accessed using the access strategy corresponding to the target to be accessed, and receives the response data returned by the target to be accessed; and a first storage module, used to store the response data returned by the first agent center in the caching middleware of the first type of network segment.
[0118] Furthermore, the control unit also includes: a second storage module, used to determine that there is a communication failure in the first communication path and store the response data in the message queue of the first agent center if the first agent center fails to store the response data; and a second acquisition module, used to control the second agent center to listen to the response data in the message queue of the first agent center, and to acquire the response data corresponding to the target request message and store the response data in the cache middleware when the response data corresponding to the target request message is detected.
[0119] Furthermore, the control unit also includes: a first update module, used to determine that there is a communication failure in the first communication path when the first agent center of the second type network segment fails to listen to the fragment queue of the adapter, and update the communication status of the first communication path with communication failure to an unreachable state; a first switching module, used to switch to the second communication path for communication when the communication status of the first communication path is unreachable, control the second agent center in the network partition to listen to the fragment queue of the adapter until a target request message is heard in the target fragment queue, and receive the target request message, wherein, after obtaining the target request message, the second agent center requests the target to be accessed on behalf of the target based on the request target field of the target request message, and receives the response data returned by the target to be accessed; and a fourth storage module, used to store the response data returned by the second agent center in the cache middleware of the first type network segment.
[0120] Furthermore, the storage unit includes: a first receiving module, used to receive response data returned by a first proxy center or a second proxy center, and store the identification information of the target request message and the response data in the form of key-value pairs in the caching middleware of the first type of network segment; and a first configuration module, used to configure an expiration time for the response data stored in the caching middleware, and to clear the response data from the caching middleware when the expiration time is reached.
[0121] The aforementioned cross-network segment communication device may also include a processor and a memory. The aforementioned receiving unit 31, query unit 32, control unit 33, storage unit 34, etc. are all stored in the memory as program units, and the processor executes the aforementioned program units stored in the memory to realize the corresponding functions.
[0122] The aforementioned processor contains a kernel, which retrieves the corresponding program units from memory. One or more kernels can be configured, and cross-network segment communication can be achieved by adjusting kernel parameters.
[0123] The aforementioned memory may include non-permanent memory in computer-readable media, such as random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM, and the memory includes at least one memory chip.
[0124] According to another aspect of the present invention, a computer-readable storage medium is also provided, the computer-readable storage medium including a stored computer program, wherein, when the computer program is executed, it controls the device where the computer-readable storage medium is located to execute any of the above-described cross-network segment communication methods.
[0125] According to another aspect of the present invention, an electronic device is also provided, including one or more processors and a memory, wherein the memory is used to store one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors cause the one or more processors to implement any of the above-described cross-network segment communication methods.
[0126] According to another aspect of the present invention, a computer program product is also provided, the computer program product including a computer program, wherein the computer program, when executed by a processor, implements any of the above-described cross-network segment communication methods.
[0127] This application also provides a computer program product, which, when executed on a data processing device, is suitable for executing an initialization program with the following method steps: receiving a target request message sent by a producer in a first-class network segment, and distributing the target request message to the target fragment queue of the adapter in the first-class network segment, wherein the adapter contains N fragment queues, where N is a positive integer, and each fragment queue is divided into a first-level fragment queue, a second-level fragment queue, and a third-level fragment queue according to priority, with the first-level fragment queue having a lower priority than the second-level fragment queue, and the second-level fragment queue having a lower priority than the third-level fragment queue; the consumer consumes the request messages of the fragment queues according to priority; determining the second-class network segment to be accessed based on the target request message, and querying the routing table based on the network segment identifier of the first-class network segment and the network segment identifier of the second-class network segment to obtain the first-class network segment and the second-class network segment. The system establishes a first communication path and a second communication path between network segments, wherein the security level of the first network segment is lower than that of the second network segment, and the communication priority of the first communication path is higher than that of the second communication path. When the communication status of the first communication path is reachable, the system controls the first proxy center of the second network segment to listen for and receive target request messages in the target shard queue. Alternatively, when the communication status of the first communication path is unreachable, the system controls the second proxy center of the network partition to listen for target request messages in the target shard queue. The first and second proxy centers are subordinate to each other. The system receives response data returned by either the first or second proxy center and stores the response data in the cache middleware of the first network segment. The producer reads the response data corresponding to the target request message from the cache middleware through a polling method.
[0128] Figure 4 This is a hardware structure block diagram of an electronic device (or mobile device) that performs a cross-network segment communication method according to an embodiment of the present invention. Figure 4 As shown, an electronic device may include one or more processors ( Figure 4The processor, denoted by 402a, 402b, ..., 402n, can include, but is not limited to, a processing device such as a microprocessor (MCU) or a programmable logic device (FPGA), and a memory 404 for storing data. In addition, it may include: a display, an input / output interface (I / O interface), a universal serial bus (USB) port (which may be included as one of the ports in the I / O interface), a network interface, a keyboard, a power supply, and / or a camera. Those skilled in the art will understand that... Figure 4 The structure shown is for illustrative purposes only and does not limit the structure of the electronic device described above. For example, the electronic device may also include components that are more... Figure 4 The more or fewer components shown, or having the same Figure 4 The different configurations shown.
[0129] The sequence numbers of the above embodiments of the present invention are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.
[0130] In the above embodiments of the present invention, the descriptions of each embodiment have different focuses. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions of other embodiments.
[0131] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. The device embodiments described above are merely illustrative; for example, the division of units can be a logical functional division, and in actual implementation, there may be other division methods. For instance, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the displayed or discussed mutual coupling, direct coupling, or communication connection may be through some interfaces; the indirect coupling or communication connection between units or modules may be electrical or other forms.
[0132] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0133] Furthermore, the functional units in the various embodiments of the present invention can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
[0134] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, read-only memory (ROM), random access memory (RAM), portable hard drives, magnetic disks, or optical disks.
[0135] The above description is only a preferred embodiment of the present invention. It should be noted that for those skilled in the art, several improvements and modifications can be made without departing from the principle of the present invention, and these improvements and modifications should also be considered within the scope of protection of the present invention.
Claims
1. A cross-network segment communication method, characterized in that, include: The system receives target request messages sent by producers in the first type of network segment and distributes the target request messages to the target shard queues of the adapter in the first type of network segment. The adapter contains N shard queues, where N is a positive integer. Each shard queue is divided into a first-level shard queue, a second-level shard queue, and a third-level shard queue according to priority. The priority of the first-level shard queue is lower than that of the second-level shard queue, and the priority of the second-level shard queue is lower than that of the third-level shard queue. Consumers consume request messages from shard queues according to priority. Based on the target request message, the second type of network segment to be accessed is determined, and the routing table is queried based on the network segment identifier of the first type of network segment and the network segment identifier of the second type of network segment to obtain the first communication path and the second communication path between the first type of network segment and the second type of network segment. The security level of the first type of network segment is lower than that of the second type of network segment, and the communication priority of the first communication path is higher than that of the second communication path. When the communication status of the first communication path is reachable, the first proxy center of the second type of network segment is controlled to listen to and receive target request messages in the target fragment queue; or, when the communication status of the first communication path is unreachable, the second proxy center of the network partition is controlled to listen to target request messages in the target fragment queue, wherein the first proxy center and the second proxy center are subordinate to each other. The producer receives response data returned by the first proxy center or the second proxy center and stores the response data in the caching middleware of the first type of network segment. The producer reads the response data corresponding to the target request message from the caching middleware by polling.
2. The method according to claim 1, characterized in that, The step of distributing the target request message to the target fragment queue of the adapter in the first type of network segment includes: The request message is parsed to obtain message attributes; Calculate the hash value based on the message attributes, and determine the shard queue to be distributed based on the hash value; Obtain the priority of the request message, and determine the target shard queue based on the shard queue to be distributed and the priority; The target request message is distributed to the target shard queue.
3. The method according to claim 1, characterized in that, Before receiving the target request message sent by the producer in the first type of network segment, it also includes: Obtain all communication network segments and perform route registration for the communication network segments, wherein the communication network segments are divided into Class I network segments and Class II network segments based on the security level; Path planning is performed between the first type of network segment and the second type of network segment to generate communication paths between each of the first type of network segment and each of the second type of network segment, wherein the communication path includes at least: the first communication path and the second communication path; The routing table is created based on the first type of network segment, the second type of network segment, and the communication path between the first type of network segment and the second type of network segment.
4. The method according to claim 1, characterized in that, When the communication status of the first communication path is reachable, the step of controlling the first proxy center of the second type of network segment to listen for and receive target request messages in the target fragment queue includes: Obtain the initial communication state of the first communication path, wherein the initial communication state is a reachable state; When the first communication path is reachable, the first proxy center of the second type of network segment is controlled to listen to the fragment queue of the adapter until the target request message in the target fragment queue is heard, and the target request message is received. After receiving the target request message, the first proxy center determines the target to be accessed based on the request target field of the target request message, and accesses the target to be accessed using the access strategy corresponding to the target to be accessed, and receives the response data returned by the target to be accessed. The response data returned by the first proxy center is stored in the caching middleware of the first type of network segment.
5. The method according to claim 4, characterized in that, After storing the response data returned by the first proxy center in the caching middleware of the first type of network segment, the method further includes: If the first proxy center fails to store the response data, it is determined that there is a communication failure in the first communication path, and the response data is stored in the message queue of the first proxy center; The second proxy center is controlled to listen to the response data in the message queue of the first proxy center, and when the response data corresponding to the target request message is detected, the response data corresponding to the target request message is obtained and the response data is stored in the cache middleware.
6. The method according to claim 4, characterized in that, When the communication status of the first communication path is unreachable, the step of controlling the second proxy center of the network partition to listen to the target request messages of the target shard queue includes: When the first agent center controlling the second type of network segment fails to listen to the fragment queue of the adapter, it is determined that there is a communication failure in the first communication path, and the communication status of the first communication path with communication failure is updated to unreachable. When the communication status of the first communication path is unreachable, the second communication path is switched to communicate. The second proxy center in the network partition is controlled to listen to the fragment queue of the adapter until the target request message in the target fragment queue is heard. The target request message is received. After obtaining the target request message, the second proxy center requests the target to be accessed on behalf of the target based on the request target field of the target request message, and receives the response data returned by the target to be accessed. The response data returned by the second proxy center is stored in the caching middleware of the first type of network segment.
7. The method according to claim 1, characterized in that, The step of receiving response data returned by the first proxy center or the second proxy center and storing the response data in the caching middleware of the first type of network segment includes: Receive response data returned by the first proxy center or the second proxy center, and store the identification information of the target request message and the response data in the form of key-value pairs in the cache middleware of the first type of network segment; Configure an expiration time for the response data stored in the cache middleware, and clear the response data from the cache middleware when the expiration time is reached.
8. A cross-network segment communication device, characterized in that, include: The receiving unit is configured to receive target request messages sent by producers in the first type of network segment, and distribute the target request messages to the target shard queues of the adapter in the first type of network segment. The adapter contains N shard queues, where N is a positive integer. Each shard queue is divided into a first-level shard queue, a second-level shard queue, and a third-level shard queue according to priority. The priority of the first-level shard queue is lower than that of the second-level shard queue, and the priority of the second-level shard queue is lower than that of the third-level shard queue. Consumers consume the request messages of the shard queues according to their priorities. The query unit is used to determine the second type of network segment to be accessed based on the target request message, and query the routing table based on the network segment identifier of the first type of network segment and the network segment identifier of the second type of network segment to obtain the first communication path and the second communication path between the first type of network segment and the second type of network segment, wherein the security level of the first type of network segment is lower than the security level of the second type of network segment, and the communication priority of the first communication path is higher than the communication priority of the second communication path. The control unit is configured to control the first proxy center of the second type of network segment to listen to and receive target request messages in the target fragment queue when the communication status of the first communication path is reachable; or, when the communication status of the first communication path is unreachable, control the second proxy center of the network partition to listen to target request messages in the target fragment queue, wherein the first proxy center and the second proxy center are subordinate to each other. A storage unit is used to receive response data returned by the first proxy center or the second proxy center, and store the response data in the caching middleware of the first type of network segment, wherein the producer reads the response data corresponding to the target request message from the caching middleware in a polling manner.
9. A computer-readable storage medium, characterized in that, The computer-readable storage medium includes a stored computer program, wherein, when the computer program is executed, it controls the device containing the computer-readable storage medium to perform the cross-segment communication method according to any one of claims 1 to 7.
10. An electronic device, characterized in that, It includes one or more processors and a memory, the memory being used to store one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors cause the one or more processors to implement the cross-segment communication method according to any one of claims 1 to 7.
Citation Information
Patent Citations
CN119211335A
WO2022237507A1