A message request processing method, apparatus, electronic device, and storage medium

By adding environment identifiers and service address mappings to the proxy server, the problems of high resource consumption and large changes to business code in Kafka cluster environment isolation are solved, achieving seamless environment isolation, reducing resource consumption and maintenance costs, and improving user experience.

CN116805946BActive Publication Date: 2025-10-28TENCENT TECHNOLOGY (SHENZHEN) CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210271272.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-03-18
Publication Date
2025-10-28
Estimated Expiration
2042-03-18

AI Technical Summary

Technical Problem

In existing technologies, Kafka cluster environment isolation methods result in high resource consumption or frequent changes to business code, and cannot effectively achieve topic isolation between clients in different environments and the Kafka cluster.

Method used

By adding an environment identifier to the proxy server and utilizing environment port mapping information and service address mapping information, the mapping relationship between topic environment identifiers and service addresses is realized. The proxy server adds the environment identifier in the Topic information to enable interaction between the client and the Kafka cluster, avoiding direct modification of business code.

Benefits of technology

Without intruding on business logic code, topic isolation between clients in different environments and the Kafka cluster was achieved, reducing resource consumption and maintenance costs, preventing message anomalies, and improving user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116805946B_ABST
    Figure CN116805946B_ABST
Patent Text Reader

Abstract

This invention discloses a message request processing method, apparatus, electronic device, and storage medium. The method includes: obtaining a first message request with a non-metadata request type based on a target port; adding a target environment identifier to the content of a first field associated with a target topic identifier in the first message request to obtain a target first message request; determining matching target service address mapping information in service address mapping information based on the target topic identifier and the target environment identifier; sending the target first message request based on the target service address in the target service address mapping information, obtaining message data returned in response to the target first message request; deleting the target environment identifier from the message data to obtain target message data, and returning the target message data to the requester of the first message request. This invention achieves environmental isolation of topics interacting between clients in different environments and the Kafka cluster while reducing resource consumption and ensuring non-intrusive business code.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of computer technology, and in particular to a message request processing method, apparatus, electronic device, and storage medium. Background Technology

[0002] Kafka is a message system based on a publish / subscribe pattern. In Kafka, messages are categorized by topic. Producers produce messages, and consumers consume messages, both oriented towards topics. A topic refers to a message subject, representing a type of message. Producers and consumers communicate through topics; a producer is a client program that publishes messages to a topic, and a consumer is a client program that subscribes to messages on a topic.

[0003] In related technologies, to achieve environment isolation between clients in different environments and Kafka, two approaches are used: one is Kafka multi-instance isolation, where different environments use independent Kafka clusters, and each environment connects to its corresponding Kafka cluster independently without interference; the other is client-side code-level topic isolation, where different topics are produced / consumed at the code level. The first approach requires a separate Kafka cluster instance for each environment, resulting in significant resource consumption. The second approach requires adding environment identifiers to all topic information involved in client production / consumption before interacting with the Kafka cluster, which intrudes on the business code and leads to high costs for business service modifications and maintenance. Summary of the Invention

[0004] To address the problems of existing technologies, embodiments of the present invention provide a message request processing method, apparatus, electronic device, and storage medium. The technical solution is as follows:

[0005] On the one hand, a message request processing method is provided, the method comprising:

[0006] The first message request is obtained based on the target port; the request type of the first message request is a non-metadata request.

[0007] A target environment identifier is added to the content of the first field associated with the target topic identifier in the first message request to obtain the target first message request; the target environment identifier is the environment identifier corresponding to the target port determined based on the environment port mapping information, and the environment port mapping information represents the correspondence between the environment identifier and the port address;

[0008] Based on the target topic identifier and the target environment identifier, the matching target service address mapping information in the service address mapping information is determined; the service address mapping information represents the correspondence between the topic environment identifier and the service address, the topic environment identifier includes the topic identifier and the environment identifier, and the service address is the address of the message server in the message server cluster;

[0009] Based on the target service address in the target service address mapping information, send the target first message request and obtain the message data returned in response to the target first message request;

[0010] The target message data is obtained by deleting the target environment identifier from the message data, and the target message data is returned to the requester of the first message request; the business environment of the requester is the target environment corresponding to the target environment identifier.

[0011] On the other hand, a message request processing apparatus is provided, the apparatus comprising:

[0012] The first message request acquisition module is used to acquire the first message request based on the target port; the request type of the first message request is a non-metadata request.

[0013] The first step identifier addition module is used to add a target environment identifier to the content of the first field associated with the target topic identifier in the first message request to obtain the target first message request; the target environment identifier is the environment identifier corresponding to the target port determined based on the environment port mapping information, and the environment port mapping information represents the correspondence between the environment identifier and the port address;

[0014] The first mapping information determination module is used to determine the matching target service address mapping information in the service address mapping information based on the target topic identifier and the target environment identifier; the service address mapping information represents the correspondence between the topic environment identifier and the service address, the topic environment identifier includes a topic identifier and an environment identifier, and the service address is the address of the message server in the message server cluster;

[0015] The first sending module is used to send the target first message request based on the target service address in the target service address mapping information, and to obtain message data returned in response to the target first message request.

[0016] The first data return module is used to delete the target environment identifier from the message data to obtain target message data, and return the target message data to the requester of the first message request; the business environment of the requester is the target environment corresponding to the target environment identifier.

[0017] In one exemplary embodiment, the apparatus further includes:

[0018] The second message request acquisition module is used to acquire the second message request sent by the requester to the message server cluster based on the target port; the request type of the second message request is a metadata request.

[0019] The second environment identifier adding module is used to add the target environment identifier to the second field content associated with the target topic identifier in the second message request to obtain the target second message request;

[0020] The second sending module is used to send the target second message request to the message server cluster and obtain the metadata information returned by the message server cluster; the metadata information includes the address information of the message server in the message server cluster corresponding to the target topic environment identifier;

[0021] The service address mapping information generation module is used to generate the target service address mapping information based on the address information of the message server corresponding to the target topic environment identifier;

[0022] The metadata processing module is used to replace the address information of the message server in the metadata information with the target port address of the target port, and delete the target environment identifier in the metadata information to obtain the target metadata information;

[0023] The second data return module is used to return the target metadata information to the requester, so that the requester can send the first message request to the target port based on the target port address in the target metadata information.

[0024] In one exemplary implementation, the second message request acquisition module is specifically used to receive the second message request intercepted and forwarded by the requester based on the target forwarding rule;

[0025] The target forwarding rule refers to the forwarding rule in the forwarding rule set corresponding to the target environment that matches the destination address of the second message request; the forwarding rules in the forwarding rule set are generated based on the correspondence between the service address and the target port address.

[0026] In one exemplary embodiment, the apparatus further includes:

[0027] The proxy activation module is used to respond to a proxy activation request by selecting a target port from idle ports, adjusting the target port to a working state, and obtaining the target port address of the target port; the proxy activation request includes the target environment identifier and the service address;

[0028] The forwarding rule generation and writing module is used to generate forwarding rules corresponding to the target environment identifier based on the service address and the target port address, and write the forwarding rules into the forwarding rule set of the requester;

[0029] The environment port mapping information generation module is used to generate the environment port mapping information based on the correspondence between the target environment identifier and the target port address.

[0030] In one exemplary embodiment, the apparatus further includes:

[0031] The proxy shutdown module is used to respond to a proxy shutdown request and determine the matching target mapping information in the environment port mapping information based on the target environment identifier in the proxy shutdown request; the target mapping information indicates the correspondence between the target environment identifier and the target port address.

[0032] The forwarding rule deletion module is used to delete the corresponding forwarding rule from the forwarding rule set of the requester based on the service address and the target port address in the proxy shutdown request;

[0033] The port mapping information adjustment module is used to adjust the target port corresponding to the target port address to be in an idle state and delete the target mapping information.

[0034] In one exemplary implementation, the agent activation module includes:

[0035] The polling module is used to send detection requests to idle ports in turn in response to proxy activation requests.

[0036] The target port determination module is used to determine any idle port as the target port when it receives response information returned by any of the idle ports.

[0037] On the other hand, a message request processing apparatus is provided, the apparatus comprising:

[0038] The business server is used to send a first message request to the target port of the proxy server; the request type of the first message request is a non-metadata request.

[0039] A proxy server is configured to add a target environment identifier to the first field content associated with the target topic identifier in the first message request to obtain a target first message request; determine matching target service address mapping information in the service address mapping information based on the target topic identifier and the target environment identifier; and send the target first message request to the message server cluster based on the target service address in the target service address mapping information; wherein, the target environment identifier is an environment identifier corresponding to the target port determined based on the environment port mapping information, and the environment port mapping information represents the correspondence between the environment identifier and the port address; the service address mapping information represents the correspondence between the topic environment identifier and the service address, the topic environment identifier includes a topic identifier and an environment identifier, and the service address is the address of the message server in the message server cluster;

[0040] A message server cluster is used to return message data to the proxy server in response to the first message request from the target.

[0041] The proxy server is also used to obtain the message data; delete the target environment identifier from the message data to obtain target message data, and return the target message data to the business server.

[0042] On the other hand, an electronic device is provided, including a processor and a memory, wherein the memory stores at least one instruction or at least one program, the at least one instruction or the at least one program being loaded and executed by the processor to implement the message request processing method described above.

[0043] On the other hand, a computer-readable storage medium is provided, wherein at least one instruction or at least one program is stored therein, the at least one instruction or the at least one program being loaded and executed by a processor to implement the message request processing method as described above.

[0044] On the other hand, a computer program product or computer program is provided, which includes computer instructions stored in a computer-readable storage medium. A processor of an electronic device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the electronic device to perform the aforementioned message request processing method.

[0045] This invention, through its embodiments, obtains a first message request (non-metadata request) sent by a requester in a target environment based on a target port. It then adds a target environment identifier to the first field associated with the target topic identifier in the first message request to obtain the target first message request. Based on the target topic identifier and the target environment identifier, it determines the target service address mapping information in the service address mapping information. The target first message request is then sent based on the target service address in the target service address mapping information, and the returned message data is obtained. The target environment identifier is removed from the returned message data to obtain the target message data, which is then sent to the aforementioned requester. This achieves environmental isolation between clients in different environments and the Kafka cluster, while reducing resource consumption, ensuring the business code is unaware of the interaction, and operating without intrusion. Attached Figure Description

[0046] To more clearly illustrate the technical solutions in the embodiments of the present invention, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0047] Figure 1a It is a Kafka multi-instance isolation technology solution in the existing technology;

[0048] Figure 1b It is a client-side code-level topic isolation technology solution in existing technologies;

[0049] Figure 2a This is a schematic diagram of an architecture for a message request processing method provided in an embodiment of the present invention;

[0050] Figure 2b This is another schematic diagram of the architecture provided in the embodiment of the present invention;

[0051] Figure 3 This is a flowchart illustrating a message request processing method provided in an embodiment of the present invention;

[0052] Figure 4 This is a flowchart illustrating another message request processing method provided in an embodiment of the present invention;

[0053] Figure 5 This is a schematic diagram of the proxy port activation and deactivation process provided in an embodiment of the present invention;

[0054] Figure 6 This is a structural block diagram of a message request processing device provided in an embodiment of the present invention;

[0055] Figure 7This is a hardware structure block diagram of an electronic device provided in an embodiment of the present invention. Detailed Implementation

[0056] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. 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 are within the scope of protection of the present invention.

[0057] 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 non-exclusive inclusion; for example, a process, method, system, product, or server 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 devices.

[0058] It is understood that in the specific embodiments of this application, data such as user information are involved. When the above embodiments of this application are applied to specific products or technologies, user permission or consent is required, and the collection, use and processing of related data must comply with the relevant laws, regulations and standards of the relevant countries and regions.

[0059] The embodiments of the present invention can be applied to various scenarios, including but not limited to cloud technology, artificial intelligence, smart transportation, and assisted driving.

[0060] Cloud computing is a computing model that distributes computing tasks across a resource pool composed of a large number of computers, enabling various application systems to access computing power, storage space, and information services as needed. The network providing these resources is called the "cloud." From the user's perspective, the resources in the "cloud" are infinitely scalable, readily available, on-demand, expandable, and pay-as-you-go. As a provider of fundamental cloud computing capabilities, a cloud resource pool (referred to as a cloud platform, generally called an IaaS (Infrastructure as a Service) platform) is established. Various types of virtual resources are deployed within this pool for external customers to choose from. The cloud resource pool mainly includes: computing devices (virtualized machines containing operating systems), storage devices, and network devices. Logically, a PaaS (Platform as a Service) layer can be deployed on top of the IaaS layer, and a SaaS (Software as a Service) layer can be deployed on top of the PaaS layer. Alternatively, SaaS can be directly deployed on top of IaaS. PaaS is a platform for running software, such as databases and web containers. SaaS refers to various types of business software, such as web portals and bulk SMS senders. Generally, SaaS and PaaS are upper layers compared to IaaS.

[0061] Cloud storage is a new concept that extends and develops from the concept of cloud computing. A distributed cloud storage system (hereinafter referred to as a storage system) refers to a storage system that uses cluster applications, grid technology, and distributed storage file systems to bring together a large number of storage devices of various types (storage devices are also called storage nodes) in the network to work together through application software or application interfaces to provide data storage and business access functions to the outside world.

[0062] Currently, the storage method of storage systems is as follows: Logical volumes are created. During the creation of a logical volume, physical storage space is allocated to each logical volume. This physical storage space may consist of a single storage device or the disks of several storage devices. Clients store data on a logical volume, which means storing the data on the file system. The file system divides the data into many parts, each part being an object. Each object contains not only the data but also additional information such as a data identifier (ID, ID entity). The file system writes each object to the physical storage space of that logical volume and records the storage location information of each object. Therefore, when a client requests access to data, the file system can allow the client to access the data based on the storage location information of each object.

[0063] The process by which a storage system allocates physical storage space to a logical volume is as follows: the physical storage space is pre-divided into strips according to the capacity estimate of the objects stored in the logical volume (this estimate often has a large margin relative to the actual capacity of the objects to be stored) and the grouping of Redundant Array of Independent Disks (RAID). A logical volume can be understood as a strip, thus allocating physical storage space to the logical volume.

[0064] The following is a description of the terminology that may be involved in the embodiments of the present invention.

[0065] Kakfa: A messaging system based on the publish / subscribe pattern.

[0066] Broker: A single Kafka server is a broker. A cluster consists of at least one broker. A broker can host multiple topics.

[0067] ZooKeeper is a distributed coordination framework responsible for coordinating, managing, and storing all metadata information of the Kafka cluster. This includes information such as which brokers are running in the cluster, which topics have been created, how many partitions each topic has, and which machines host the leader replicas of these partitions.

[0068] Topic: The subject of a message, representing a type of message. Producers and consumers communicate through topics.

[0069] Producer: A client program that publishes messages to a topic.

[0070] Consumer: A client program that subscribes to topic messages.

[0071] CI / CD: Continuous Integration and Continuous Deployment;

[0072] DevOps: A combination of Development and Operations, it's a culture, movement, or practice that emphasizes communication and collaboration between software developers (Dev) and IT operations professionals (Ops). It aims to make building, testing, and releasing software faster, more frequent, and more reliable by automating the processes of software delivery and architectural changes.

[0073] Serialization: Converting a data structure or object into a binary data stream.

[0074] Deserialization: Converting a binary data stream into an actual data structure or object.

[0075] In related technologies, clients interacting with a Kafka cluster are typically located in different environments. For example, clients in the development process and clients in the testing process reside in development and testing environments, respectively. It should be noted that in this embodiment of the invention, the client's environment can be divided based on the specific unit requiring independent interaction with the Kafka cluster in the actual application. For example, when it is necessary for different developers in the development process to interact with the Kafka cluster without interference, the clients corresponding to different developers in the development process can be divided into clients in different environments. To achieve environment isolation between clients in different environments and Kafka, one approach is to use Kafka multi-instance isolation, with different environments using independent Kafka clusters. In this approach, each environment has its own independent Kafka cluster, and business services in different environments only need to connect to the Kafka cluster corresponding to that environment. Figure 1a As shown, Environment Env1 and Environment Env2 each correspond to independent Kafka clusters, connected separately without interference. Since each environment requires a Kafka cluster instance—for example, a Kafka cluster needs at least 2 servers (1 broker + 1 zookeeper), and for high availability, at least 6 servers (3 brokers + 3 zookeepers) are needed—there would be N environments, requiring at least 2N servers, and for high availability, at least 6N servers, resulting in significant resource consumption.

[0076] Another approach is to use client-side code-level topic isolation, where different topics are produced / consumed at the business logic level. For example... Figure 1b As shown, the producer and consumer services connect to the same Kafka cluster. Based on their respective environments, the producer and consumer services configure requests to the Kafka cluster at the business code level. Production / consumption corresponds to the Topic-Environment ID (e.g., ...). Figure 1b In this approach, Topic-Env1 and Topic-Env2 are processed separately by the Kafka cluster due to the different Topic IDs (i.e., Topic-Env1 environment identifiers), achieving environment isolation. However, this method requires intrusion into the business logic code. The business logic code must add environment identifiers to all Topic information involved in client production / consumption before interacting with the Kafka cluster. Because this requires code intrusion, the modification and maintenance costs are high. Furthermore, if the business logic code is not fully modified, message anomalies will occur (e.g., if consuming Topic-Env1 is required, the lack of injected Topic-Env1 environment ID will result in producing / consuming the original Topic), hindering troubleshooting.

[0077] Based on this, this invention proposes a message request processing method. This method not only reduces resource consumption while achieving multi-environment isolation, but also does not intrude on business code. Through unified isolation via a proxy, the business code is unaware of the changes. Businesses only need to maintain one set of code, which reduces the cost of modifying and maintaining business code, and also avoids message anomalies caused by incomplete modification of business code.

[0078] The application environment of the embodiments of the present invention will be described below.

[0079] Please see Figure 2a The diagram shows an architecture of a message request processing method provided in an embodiment of the present invention, including a business server 210, a proxy server 220 and a message server cluster 230, wherein the business server 210, the proxy server 220 and the message server cluster 230 can communicate with each other via wired or wireless network.

[0080] Among them, the business server 210 provides backend services for producers / consumers. Specifically, the backend service can be sending message requests to the message server cluster 230. Producers / consumers can be in different business environments. The business environment of the business server 210 corresponds to the corresponding producer / consumer. That is, the business server 210 can include business servers in different business environments (such as business environment Dev1, business environment Dev2), and each business environment can correspond to multiple business servers.

[0081] Proxy server 220 acts as an intermediary between business server 210 and message server cluster 230. Through proxy server 220, business server 210 and message server cluster 230 do not interact directly. That is, message requests sent by business server 210 need to be sent to message server cluster 230 through proxy server 220. Specifically, proxy server 220 can receive message requests through ports corresponding to each environment and add the environment identifier of the corresponding port (such as Topic-Dev1, Topic-Dev2) to the Topic information of the message request to achieve multi-environment isolation without the business being aware of it.

[0082] The message server cluster 230 is a message system based on the publish / subscribe pattern, such as a Kafka cluster. Taking a Kafka cluster as an example, a Kafka cluster can consist of multiple brokers, each broker being a Kafka server, and each broker can hold multiple topics.

[0083] The technical solution of this invention can be applied to CI / CD-related DevOps platform products, enabling Kafka environment isolation during development, testing, and other related phases, thus improving user experience. In typical application scenarios such as business development processes, this invention can be used to isolate Kafka environments connected to different developers, achieving the goal of non-interference between different developers. Figure 2a As shown: Developer 1's request ultimately does not interfere with Developer 2's request.

[0084] Figure 2b The diagram illustrates another architecture of this invention. The proxy server 220 may include a proxy management module 221 and a proxy module 222. The proxy management module 221 controls the opening and closing of the proxy port for the corresponding environment in the proxy module 222, and controls the traffic forwarding rules of the producer / consumer backend service (i.e., the business server) corresponding to the business environment. The proxy module 222 is responsible for data interaction with the producer / consumer backend service (i.e., the business server) of the business environment, controlling the injection of the corresponding environment identifier into the transmitted data, and interacting with the message server cluster instance, achieving multi-environment isolation and seamless business operation.

[0085] It should be noted that the server in this embodiment of the invention can be an independent physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server providing basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, CDN, and big data and artificial intelligence platforms. The client can be a hardware device with various operating systems, such as a smartphone, desktop computer, tablet computer, or laptop computer, or software configured on the aforementioned hardware device, such as an application. Specifically, the client can be a smartphone, tablet computer, laptop computer, desktop computer, smart speaker, smartwatch, etc., but is not limited to these.

[0086] In one exemplary implementation, the aforementioned client, server, and cluster can all be node devices in a blockchain system, capable of sharing acquired and generated information with other node devices in the blockchain system, thus achieving information sharing among multiple node devices. Multiple node devices in the blockchain system can be configured with the same blockchain, which consists of multiple blocks, and adjacent blocks are related, ensuring that any data tampering in any block can be detected by the next block, thereby preventing data tampering in the blockchain and guaranteeing the security and reliability of the data in the blockchain.

[0087] The following combination Figure 2a and Figure 2b The technical solutions of the embodiments of the present invention will be described in detail.

[0088] Please see Figure 3 The diagram shown is a flowchart of a message request processing method provided by an embodiment of the present invention. This method can be applied to... Figure 2a The proxy server in the process. It should be noted that this specification provides the operational steps of the methods described in the embodiments or flowcharts, but based on conventional or non-inventive labor, more or fewer operational steps may be included. The order of steps listed in the embodiments is merely one possible execution order among many, and does not represent the only execution order. In actual system or product execution, the methods shown in the embodiments or figures can be executed sequentially or in parallel (e.g., in a parallel processor or multi-threaded processing environment). Specifically, as shown... Figure 3 As shown, the method may include:

[0089] S301, obtain the first message request based on the target port.

[0090] The first message request is a non-metadata request, meaning that the first message request is not used to request metadata information of the message server cluster. Typically, the metadata information of the message server cluster describes which message servers are running in the cluster, which topics have been created, how many partitions each topic has, and which message servers hold the control replicas of these partitions.

[0091] It should be noted that the first message request is sent by the requester whose business environment is the target environment. This requester can be the backend business server corresponding to the producer / consumer. There is a one-to-one correspondence between the target environment and the target port. That is to say, the target port on the proxy server is only used to obtain the first message request from the target environment. However, it should be noted that the first message request does not carry the environment identifier of the target environment.

[0092] In practice, in order to ensure that the first message request from the target environment can reach the target port of the proxy server, the target port address of the target port needs to be returned to the requester in the target environment as the destination address before the requester in the target environment sends the first message request based on the target port address, so that the first message request from the target environment can reach the target port of the proxy server.

[0093] Based on this, in an exemplary implementation, such as Figure 4 As shown, before step S301, which obtains the first message request based on the target port, the method may further include:

[0094] S401, Obtain the second message request sent by the requester to the message server cluster based on the target port.

[0095] The second message request is a metadata request, meaning it is used to request metadata information from the message server cluster.

[0096] Normally, the target port of the proxy server cannot receive metadata requests sent to the message server cluster by the requester in the target environment because the destination address of the metadata request points to the message server cluster. To enable the target port of the proxy server to obtain metadata requests from the requester in the target environment to the message server cluster, in this embodiment of the invention, forwarding rules are pre-written into the business server of the target environment. These forwarding rules are generated based on the correspondence between the service addresses of the message servers in the message server cluster and the target port addresses. The forwarding rules instruct that requests with the destination address being the aforementioned service address be forwarded to the target port address. Therefore, during the implementation of step S401 above, the proxy server can receive metadata requests intercepted and forwarded by the requester in the target environment based on the target forwarding rules.

[0097] The target forwarding rule refers to the forwarding rule in the forwarding rule set corresponding to the target environment that matches the destination address of the second message request; the forwarding rules in the forwarding rule set are generated based on the correspondence between the service addresses of the message servers in the message server cluster and the target port addresses. The generation of forwarding rules and their writing to the business server will be described in detail in the subsequent content of this embodiment.

[0098] Traffic destined for the message server cluster can be intercepted and forwarded by the business server based on pre-written forwarding rules. The specific traffic interception and forwarding tool can be iptables, and the set of forwarding rules can be the iptables rule list. Of course, other effective traffic interception and forwarding tools can also be used, such as Envoy or similar interception and forwarding tools that forward traffic at the code level.

[0099] S403, add a target environment identifier to the content of the second field associated with the target topic identifier in the second message request to obtain the target second message request.

[0100] The target topic identifier refers to the identifier corresponding to the message topic of the first message request. The message topic of the metadata requests preceding the first message request includes the message topic of the first message request.

[0101] In practice, the second message request can be deserialized based on a protocol format (such as the Kafka protocol format) to obtain the corresponding request header and request body. Then, a target environment identifier is added to all fields in the request body that involve the target topic identifier. The target environment identifier is the environment identifier corresponding to the target port determined based on environment port mapping information. This environment port mapping information represents the correspondence between the environment identifier and the port address. The port address includes the target port address corresponding to the target port, and the environment identifier includes the target environment identifier of the target environment.

[0102] S405, the target second message request is sent to the message server cluster, and the metadata information returned by the message server cluster is obtained.

[0103] The metadata information includes the address information of the message server corresponding to the target topic environment identifier in the message server cluster. The target topic environment identifier includes a target environment identifier and a target topic identifier, for example, it can be represented as test-topic-dev1. In other words, the metadata information indicates which message servers in the message server cluster are used to process message requests corresponding to the target topic environment identifier.

[0104] In practice, the target second message request can be serialized first, and then the serialized target second message request can be sent to the message server cluster.

[0105] S407, Based on the address information of the message server corresponding to the target topic environment identifier, generate target service address mapping information.

[0106] The target service address mapping information represents the correspondence between the target topic environment identifier and the address information of its corresponding message server. For example, if the target topic environment identifier is test-topic-dev1, then the target service address mapping information can be represented as test-topic-dev1 => 1.1.1.1:9092.

[0107] It is understandable that the representation of the target service address mapping information is not limited to the above. It can also include the server identifier of the corresponding message server. Taking a Kafka cluster as an example, the target service address mapping information can be test-topic-dev1 => 1 => 1.1.1.1:9092, where 1 is the corresponding Broker ID and 1.1.1.1:9092 is the Broker host address.

[0108] In specific implementation, after obtaining the metadata information returned by the message server cluster, the metadata information can be deserialized to obtain the return packet header and return packet body. Then, the correspondence between the Broker ID and the Broker host address in the return packet body is cached, such as 1 => 1.1.1.1:9092. Furthermore, the correspondence between the target topic environment identifier and the Broker ID is cached to obtain the target service address mapping information.

[0109] It should be noted that the proxy server's cache stores service address mapping information, which includes the aforementioned target service address mapping information. This service address mapping information represents the correspondence between the subject environment identifier and the service address. The subject environment identifier includes a subject identifier and an environment identifier, which includes the aforementioned target subject environment identifier. The service address includes the address information from the target service address mapping information.

[0110] S409, replace the address information of the message server in the metadata information with the target port address of the target port, and delete the target environment identifier in the metadata information to obtain the target metadata information.

[0111] For example, change the original host address 1.1.1.1:9092 in the metadata information to the target port address 2.2.2.2:10000.

[0112] S411, the target metadata information is returned to the requester, so that the requester can send the first message request to the target port based on the target port address in the target metadata information.

[0113] In practice, the target metadata information can be serialized first, and then the serialized target metadata information can be returned to the requester in the target environment.

[0114] In the above embodiments, by intercepting the metadata request of the target environment to the target port of the proxy server and modifying the original host address in the corresponding return packet of the metadata request to the target port address of the target port, the requester can subsequently send the first message request with the target port address as the destination address, thereby intercepting the first message request in the target environment to the target port of the proxy server.

[0115] S303, add a target environment identifier to the content of the first field associated with the target topic identifier in the first message request to obtain the target first message request.

[0116] Specifically, the destination address of the first message request is the target port address. Based on this target port address, the environment identifier that matches the target port address in the environment port mapping information can be found to obtain the target environment identifier. The target environment corresponding to this target environment identifier is the requester's business environment. The generation of environment port mapping information will be explained later.

[0117] In practical applications, the first message request can be deserialized first. Then, the content of the first field associated with the target topic identifier in the deserialized first message request can be determined, and the found target environment identifier can be added to the first field content. For example, if the first field content includes "test-topic", then "test-topic" is the target topic identifier. Assuming the target environment identifier is "dev1", the added first field content will include "test-topic-dev1".

[0118] S305, based on the target topic identifier and the target environment identifier, determine the matching target service address mapping information in the service address mapping information.

[0119] As can be seen from the foregoing description of the embodiments of the present invention, when the proxy server obtains the first message request from the requester, it has already cached the target service address mapping information based on the interception of the requester's metadata request. Therefore, after adding the target environment identifier, the proxy server can obtain the target topic environment identifier (e.g., test-topic-dev1) based on the content of the first field after the addition, and then search for the service address mapping information that matches it in the proxy server cache based on the target topic environment identifier, which is the target service address mapping information.

[0120] S307, based on the target service address in the target service address mapping information, send the target first message request, and obtain the message data returned in response to the target first message request.

[0121] For example, if the target service address mapping information is test-topic-dev1 => 1 => 1.1.1.1:9092, then the target service address is 1.1.1.1:9092, and the target first message request can be sent to the message server with the host address 1.1.1.1:9092.

[0122] In practical applications, when sending the target first message request based on the target service address in the target service address mapping information, it is necessary to serialize the target first message request and then send the serialized target first message request based on the target service address in the target service address mapping information.

[0123] S309, the target environment identifier is deleted from the message data to obtain the target message data, and the target message data is returned to the requester of the first message request.

[0124] Since the target topic in the first message request is identified by the target topic environment identifier, the message data returned by the message server cluster is also identified by the target topic environment identifier. However, the topic identification information in the first message request sent by the requester does not contain the environment identifier. In order to avoid message anomalies, the target environment identifier in the message data needs to be deleted before returning the message data to the requester to obtain the target message data. Thus, the topic identification information in the target message data is only the target topic identifier. Returning the target message data to the requester of the first message request ensures the normal message interaction.

[0125] In practical applications, when deleting the target environment identifier from the message data to obtain the target message data and returning the target message data to the requester of the first message request, it is necessary to perform deserialization processing on the message data, delete the target environment identifier from the deserialized message data to obtain the target message data; then, perform serialization processing on the target message data and return the serialized target message data to the requester of the first message request.

[0126] As can be seen from the above technical solutions of the embodiments of the present invention, in the embodiments of the present invention, the business server does not directly interact with the message server instance, or in other words, the client does not directly interact with the message server instance. Instead, the traffic of the interaction between the business server and the message server cluster is forwarded to the proxy server. The proxy server adds an environment identifier to the Topic information and then interacts with the message server instance. Since the environment identifiers of different business environments are different, the information identifying the topic in the message requests from different environments is different. Without intruding on the business code, it is ensured that the topics of interaction between the client and the message server cluster in different environments are different, thus achieving the effect of environment isolation.

[0127] For example, suppose the current business development and testing process requires the use of N environments, and each environment requires 6 devices (3 Kafka Brokers + 3 Zookeepers), then Figure 1a Existing technical solutions require 6*N devices to achieve Kafka multi-environment isolation, while the technical solution of this invention requires only 1 + 6 devices, with 1 device being the proxy device. Therefore, if the business development and testing process requires more than one environment, this invention can reduce the number of devices by 6*N-7, significantly reducing resource consumption.

[0128] In one exemplary embodiment, the present invention further includes an activation step for the target port bound to the target environment in the proxy server. During this activation process, environment port mapping information and forwarding rules can be generated. Specifically, such as... Figure 5 The flowchart of the provided proxy port activation process may include:

[0129] S501, in response to the proxy activation request, select a target port from the idle ports, adjust the target port to be in working state and obtain the target port address of the target port.

[0130] The proxy activation request includes the target environment identifier and service address of the target environment. The service address is the destination address of the first message request, which can be the address information of any message server selected from the message server cluster.

[0131] In specific implementation, the target environment identifier and service address in the proxy activation request are information entered through the interactive interface. For example, the entered target environment identifier can be Dev1, and the entered service address can be 1.1.1.1:9092 (i.e., the address information of the message server in the message server cluster). After completing the above input, a proxy activation command can be issued through the above interactive interface, and then the proxy server receives the proxy activation request generated based on the proxy activation command.

[0132] The port status in a proxy server includes idle status and working status. The working status refers to the port status that has been identified with the corresponding environment identifier, that is, the port in the working status is in the state of receiving message requests from its corresponding environment. The idle status refers to the port status that has not yet been identified with the corresponding environment identifier.

[0133] In one example, after the target port is set to be active, the proxy server can establish a communication connection between the target port and the message server cluster to avoid reconnecting during subsequent interactions, thus improving interaction efficiency.

[0134] In one exemplary implementation, step S501, in response to the proxy activation request, selecting a target port from idle ports may include:

[0135] In response to the proxy activation request, detection requests are sent sequentially to ports that are in an idle state;

[0136] When a response is received from any of the idle ports, the idle port is identified as the target port.

[0137] Specifically, in response to a proxy activation request, the proxy server identifies currently idle ports and then sends detection requests to these ports sequentially via polling. These requests request permission to detect the corresponding port. Typically, if a port allows detection, it returns a response; otherwise, it returns nothing. Therefore, if a response is received from any idle port during the polling process, that port is identified as the target port. This method allows for the rapid identification of the target port from among idle ports.

[0138] S503, Based on the service address and the target port address, generate a forwarding rule corresponding to the target environment identifier, and write the forwarding rule into the forwarding rule set of the requester.

[0139] For example, if the input service address is 1.1.1.1:9092, the input target environment identifier is Dev1, and the target port address is 2.2.2.2:10000, then the corresponding forwarding rule for Dev1 will be 1.1.1.1:9092 => 2.2.2.2:10000. This forwarding rule will be written into the forwarding rule set of the requester (i.e., the business server) of the target environment corresponding to Dev1. The forwarding rule set of the requester corresponds to the traffic interception tool (such as iptables) running on it. Thus, when the traffic interception tool performs traffic interception, it can match the target forwarding rule corresponding to the current traffic from the forwarding rule set, and then forward the current traffic based on the target forwarding rule.

[0140] S505, generate the environment port mapping information according to the correspondence between the target environment identifier and the target port address.

[0141] Specifically, environment port mapping information represents the correspondence between environment identifiers and port addresses. This information includes target mapping information, which indicates the correspondence between target environment identifiers and target port addresses. Proxy servers can cache the generated environment port mapping information.

[0142] In the above embodiments, by using the environment identifier and service address in the proxy activation request, the ports on the proxy server can be activated dynamically and flexibly, and forwarding rules and environment port mapping information can be generated. This allows for flexible adjustment of the isolated environment, which is beneficial to improving the flexibility of subsequent message request processing.

[0143] In another exemplary implementation, for further improvements in adaptability to the isolation environment, please refer to [link to relevant documentation]. Figure 5 The method may also include the step of closing the proxy port, specifically including:

[0144] S507, in response to the proxy shutdown request, determine the matching target mapping information in the environment port mapping information based on the target environment identifier in the proxy shutdown request.

[0145] The target mapping information indicates the correspondence between the target environment identifier and the target port address.

[0146] In specific implementation, the target environment identifier and service address in the proxy shutdown request are information entered through the interactive interface. For example, the target environment identifier can be Dev1, and the service address can be 1.1.1.1:9092 (i.e., the address information of the message server in the message server cluster). After completing the above input, a proxy shutdown command can be issued through the above interactive interface, and then the proxy server receives the proxy shutdown request generated based on the proxy shutdown command.

[0147] S509, based on the service address and the target port address in the proxy shutdown request, delete the corresponding forwarding rule from the forwarding rule set of the requester.

[0148] S511, adjust the target port corresponding to the target port address to be in an idle state, and delete the target mapping information.

[0149] Understandably, this embodiment of the invention enables dynamic adjustment of the isolation environment through proxy activation and deactivation, improving the flexibility of message request processing. Business code only needs to maintain the Kafka resources required by the business itself; during development and testing, the required environment can be dynamically changed using this embodiment, thereby achieving multi-environment isolation without the business code being aware of or intrusive.

[0150] by Figure 2b Taking the application environment architecture shown as an example, users can input the environment identifier (e.g., Dev1) and the Kafka service address (e.g., 1.1.1.1:9092) through the interactive interface corresponding to the Kafka broker management module. This interactive interface has broker activation prompts and broker deactivation prompts. When the user activates the broker, a broker activation command is issued, and the Kafka broker management module receives the broker activation request based on the broker activation command. When the user deactivates the broker, a broker deactivation command is issued, and the Kafka broker management module receives the broker deactivation request based on the broker deactivation command.

[0151] For agent activation:

[0152] The Kafka broker management module can detect idle ports on the Kafka broker module. If the detection is successful, the Kafka broker module will return the port that was successfully detected (e.g., 10000) and establish a connection between port 10000 and the Kafka cluster.

[0153] After the Kafka agent management module receives the returned port, it generates forwarding rules (such as 1.1.1.1:9092 => 2.2.2.2:10000) and writes them into the forwarding rule set of the traffic interception and forwarding tool (such as iptables) corresponding to the business server (i.e., producer / consumer server Dev1) in the Dev1 environment.

[0154] The correspondence between the Kafka broker module cache environment identifier and the returned port mentioned above (Dev1 => 10000).

[0155] For proxy shutdown:

[0156] The Kafka agent management module queries the cached environment identifier and port mapping, removes the forwarding rules corresponding to the traffic interception and forwarding tools (such as iptables) generated by the business server in the above activation steps, notifies the Kafka agent module to turn off the detection of the above-queried ports, and removes the cached data of the corresponding environment identifier and port.

[0157] Corresponding to the message request processing methods provided in the above embodiments, this embodiment of the invention also provides a message request processing apparatus. Since the message request processing apparatus provided in this embodiment of the invention corresponds to the message request processing methods provided in the above embodiments, the implementation methods of the aforementioned message request processing methods are also applicable to the message request processing apparatus provided in this embodiment, and will not be described in detail in this embodiment.

[0158] Please see Figure 6 The diagram shows a schematic representation of a message request processing device according to an embodiment of the present invention. This message request processing device 600 has the function of implementing the message request processing method described in the above-described method embodiment. This function can be implemented in hardware or by hardware executing corresponding software. Figure 6 As shown, the message request processing device 600 may include:

[0159] The first message request acquisition module 610 is used to acquire a first message request based on the target port; the request type of the first message request is a non-metadata request.

[0160] The first environment identifier adding module 620 is used to add a target environment identifier to the content of the first field associated with the target topic identifier in the first message request to obtain the target first message request; the target environment identifier is the environment identifier corresponding to the target port determined based on environment port mapping information, and the environment port mapping information represents the correspondence between the environment identifier and the port address;

[0161] The first mapping information determination module 630 is used to determine the matching target service address mapping information in the service address mapping information based on the target topic identifier and the target environment identifier; the service address mapping information represents the correspondence between the topic environment identifier and the service address, the topic environment identifier includes a topic identifier and an environment identifier, and the service address is the address of the message server in the message server cluster;

[0162] The first sending module 640 is used to send the target first message request based on the target service address in the target service address mapping information, and to obtain message data returned in response to the target first message request.

[0163] The first data return module 650 is used to delete the target environment identifier from the message data to obtain target message data, and return the target message data to the requester of the first message request; the business environment of the requester is the target environment corresponding to the target environment identifier.

[0164] In one exemplary embodiment, the apparatus further includes:

[0165] The second message request acquisition module is used to acquire the second message request sent by the requester to the message server cluster based on the target port; the request type of the second message request is a metadata request.

[0166] The second environment identifier adding module is used to add the target environment identifier to the second field content associated with the target topic identifier in the second message request to obtain the target second message request;

[0167] The second sending module is used to send the target second message request to the message server cluster and obtain the metadata information returned by the message server cluster; the metadata information includes the address information of the message server in the message server cluster corresponding to the target topic environment identifier;

[0168] The service address mapping information generation module is used to generate the target service address mapping information based on the address information of the message server corresponding to the target topic environment identifier;

[0169] The metadata processing module is used to replace the address information of the message server in the metadata information with the target port address of the target port, and delete the target environment identifier in the metadata information to obtain the target metadata information;

[0170] The second data return module is used to return the target metadata information to the requester, so that the requester can send the first message request to the target port based on the port address in the target metadata information.

[0171] In one exemplary implementation, the second message request acquisition module is specifically used to receive the second message request intercepted and forwarded by the requester based on the target forwarding rule;

[0172] The target forwarding rule refers to the forwarding rule in the forwarding rule set corresponding to the target environment that matches the destination address of the second message request; the forwarding rules in the forwarding rule set are generated based on the correspondence between the service address and the target port address.

[0173] In one exemplary embodiment, the apparatus further includes:

[0174] The proxy activation module is used to respond to a proxy activation request by selecting a target port from idle ports, adjusting the target port to a working state, and obtaining the target port address of the target port; the proxy activation request includes the target environment identifier and the service address;

[0175] The forwarding rule generation and writing module is used to generate forwarding rules corresponding to the target environment identifier based on the service address and the target port address, and write the forwarding rules into the forwarding rule set of the requester;

[0176] The environment port mapping information generation module is used to generate the environment port mapping information based on the correspondence between the target environment identifier and the target port address.

[0177] In one exemplary embodiment, the apparatus further includes:

[0178] The proxy shutdown module is used to respond to a proxy shutdown request and determine the matching target mapping information in the environment port mapping information based on the target environment identifier in the proxy shutdown request; the target mapping information indicates the correspondence between the target environment identifier and the target port address.

[0179] The forwarding rule deletion module is used to delete the corresponding forwarding rule from the forwarding rule set of the requester based on the service address and the target port address in the proxy shutdown request;

[0180] The port mapping information adjustment module is used to adjust the target port corresponding to the target port address to be in an idle state and delete the target mapping information.

[0181] In one exemplary implementation, the agent activation module includes:

[0182] The polling module is used to send detection requests to idle ports in turn in response to proxy activation requests.

[0183] The target port determination module is used to determine any idle port as the target port when it receives response information returned by any of the idle ports.

[0184] It should be noted that the apparatus provided in the above embodiments is only illustrated by the division of the above functional modules when implementing its functions. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above. In addition, the apparatus and method embodiments provided in the above embodiments belong to the same concept, and the specific implementation process can be found in the method embodiments, which will not be repeated here.

[0185] This invention also provides another message request processing device, such as... Figure 2a The diagram shows a cluster of business servers, proxy servers, and message servers, where:

[0186] The business server is used to send a first message request to the target port of the proxy server; the request type of the first message request is a non-metadata request.

[0187] A proxy server is configured to add a target environment identifier to the first field content associated with the target topic identifier in the first message request to obtain a target first message request; determine matching target service address mapping information in the service address mapping information based on the target topic identifier and the target environment identifier; and send the target first message request to the message server cluster based on the target service address in the target service address mapping information; wherein, the target environment identifier is an environment identifier corresponding to the target port determined based on the environment port mapping information, and the environment port mapping information represents the correspondence between the environment identifier and the port address; the service address mapping information represents the correspondence between the topic environment identifier and the service address, the topic environment identifier includes a topic identifier and an environment identifier, and the service address is the address of the message server in the message server cluster;

[0188] A message server cluster is used to return message data to the proxy server in response to the first message request from the target.

[0189] The proxy server is also used to obtain the message data; delete the target environment identifier from the message data to obtain target message data, and return the target message data to the business server.

[0190] Among them, the business environment of the business server is the target environment corresponding to the target environment identifier.

[0191] In an exemplary implementation, before sending the first message request to the target port of the proxy server, the service server is further configured to intercept the second message request sent to the message server cluster based on the target forwarding rule, and forward the second message request to the target port of the proxy server; the request type of the second message request is a metadata request; wherein, the target forwarding rule refers to the forwarding rule in the forwarding rule set corresponding to the target environment that matches the destination address of the second message request, and the forwarding rules in the forwarding rule set are generated based on the correspondence between the service address and the target port address;

[0192] The proxy server is further configured to: obtain the second message request based on the target port; add the target environment identifier to the second field content associated with the target topic identifier in the second message request to obtain a target second message request; send the target second message request to the message server cluster; obtain metadata information returned by the message server cluster, the metadata information including the address information of the message server corresponding to the target topic environment identifier in the message server cluster; generate the target service address mapping information based on the address information of the message server corresponding to the target topic environment identifier; replace the address information of the message server in the metadata information with the target port address of the target port, and delete the target environment identifier in the metadata information to obtain target metadata information; and return the target metadata information to the business server.

[0193] In an exemplary embodiment, the proxy server is further configured to, in response to a proxy activation request, select a target port from idle ports, adjust the target port to a working state, and obtain the target port address of the target port; the proxy activation request includes the target environment identifier and the service address; generate a forwarding rule corresponding to the target environment identifier based on the service address and the target port address, and write the forwarding rule into the forwarding rule set of the business server; and generate the environment port mapping information based on the correspondence between the target environment identifier and the target port address.

[0194] In an exemplary implementation, the proxy server is further configured to, in response to a proxy shutdown request, determine matching target mapping information in the environment port mapping information based on the target environment identifier in the proxy shutdown request; the target mapping information indicates the correspondence between the target environment identifier and the target port address; delete the corresponding forwarding rule from the forwarding rule set of the service server based on the service address and the target port address in the proxy shutdown request; adjust the target port corresponding to the target port address to be in an idle state; and delete the target mapping information.

[0195] This invention provides an electronic device including a processor and a memory. The memory stores at least one instruction or at least one program segment, which is loaded and executed by the processor to implement the message request processing method provided in the above method embodiments.

[0196] Memory can be used to store software programs and modules. The processor executes various functional applications and message request processing by running the software programs and modules stored in the memory. Memory can primarily include a program storage area and a data storage area. The program storage area can store the operating system, application programs required for functions, etc.; the data storage area can store data created based on the use of the device, etc. Furthermore, memory can include high-speed random access memory, and may also include non-volatile memory, such as at least one disk storage device, flash memory device, or other volatile solid-state storage device. Accordingly, memory may also include a memory controller to provide the processor with access to the memory.

[0197] The methods and embodiments provided in this invention can be executed on a computer terminal, server, or similar computing device. Taking running on a server as an example... Figure 7 This is a hardware structure block diagram of a server running a message request processing method according to an embodiment of the present invention, such as... Figure 7As shown, the server 700 can vary significantly due to different configurations or performance. It may include one or more central processing units (CPUs) 710 (CPUs 710 may include, but are not limited to, microprocessors such as MCUs or programmable logic devices such as FPGAs), a memory 730 for storing data, and one or more storage media 720 (e.g., one or more mass storage devices) for storing application programs 723 or data 722. The memory 730 and storage media 720 may be temporary or persistent storage. The program stored in the storage media 720 may include one or more modules, each module may include a series of instruction operations on the server. Furthermore, the CPU 710 may be configured to communicate with the storage media 720 and execute the series of instruction operations stored in the storage media 720 on the server 700. Server 700 may also include one or more power supplies 760, one or more wired or wireless network interfaces 750, one or more input / output interfaces 740, and / or one or more operating systems 721, such as Windows Server™, Mac OS X™, Unix™, Linux™, FreeBSD™, etc.

[0198] The input / output interface 740 can be used to receive or send data via a network. Specific examples of the network described above may include a wireless network provided by the communication provider of server 700. In one example, the input / output interface 740 includes a network interface controller (NIC), which can connect to other network devices via a base station to communicate with the Internet. In another example, the input / output interface 740 may be a radio frequency (RF) module for wireless communication with the Internet.

[0199] Those skilled in the art will understand that Figure 7 The structure shown is for illustrative purposes only and does not limit the structure of the aforementioned electronic device. For example, server 700 may also include... Figure 7 The more or fewer components shown, or having the same Figure 7 The different configurations shown.

[0200] Embodiments of the present invention also provide a computer-readable storage medium, which can be disposed in an electronic device to store at least one instruction or at least one program related to implementing a message request processing method, wherein the at least one instruction or the at least one program is loaded and executed by the processor to implement the message request processing method provided in the above-described method embodiments.

[0201] Embodiments of the present invention also provide a computer program product or computer program, which includes computer instructions stored in a computer-readable storage medium. A processor of an electronic device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the electronic device to perform the message request processing method described above.

[0202] Optionally, in this embodiment, the storage medium may include, but is not limited to, 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.

[0203] It should be noted that the order of the above embodiments of the present invention is merely for descriptive purposes and does not represent the superiority or inferiority of the embodiments. Furthermore, specific embodiments have been described above. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps described in the claims can be performed in a different order than that shown in the embodiments and still achieve the desired result. Additionally, the processes depicted in the drawings do not necessarily require a specific or sequential order to achieve the desired result. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.

[0204] The various embodiments in this specification are described in a progressive manner. Similar or identical parts between embodiments can be referred to mutually. Each embodiment focuses on describing the differences from other embodiments. In particular, the apparatus embodiments are basically similar to the method embodiments, so the description is relatively simple; relevant parts can be referred to the descriptions of the method embodiments.

[0205] Those skilled in the art will understand that all or part of the steps of the above embodiments can be implemented by hardware or by a program instructing related hardware. The program can be stored in a computer-readable storage medium, such as a read-only memory, a disk, or an optical disk.

[0206] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the protection scope of the present invention.

Claims

1. A message request processing method, characterized in that, The method includes: The first message request is obtained based on the target port; the request type of the first message request is a non-metadata request. A target environment identifier is added to the content of the first field associated with the target topic identifier in the first message request to obtain the target first message request; the target environment identifier is the environment identifier corresponding to the target port determined based on the environment port mapping information, and the environment port mapping information represents the correspondence between the environment identifier and the port address; Based on the target topic identifier and the target environment identifier, the matching target service address mapping information in the service address mapping information is determined; the service address mapping information represents the correspondence between the topic environment identifier and the service address, the topic environment identifier includes the topic identifier and the environment identifier, and the service address is the address of the message server in the message server cluster; Based on the target service address in the target service address mapping information, send the target first message request and obtain the message data returned in response to the target first message request; The target message data is obtained by deleting the target environment identifier from the message data, and the target message data is returned to the requester of the first message request; the business environment of the requester is the target environment corresponding to the target environment identifier.

2. The message request processing method according to claim 1, characterized in that, Before obtaining the first message request based on the target port, the method further includes: The second message request sent by the requester to the message server cluster is obtained based on the target port; the request type of the second message request is a metadata request. Add the target environment identifier to the content of the second field associated with the target topic identifier in the second message request to obtain the target second message request; The target second message request is sent to the message server cluster, and the metadata information returned by the message server cluster is obtained; the metadata information includes the address information of the message server in the message server cluster corresponding to the target topic environment identifier; Based on the address information of the message server corresponding to the target topic environment identifier, the target service address mapping information is generated; Replace the message server address information in the metadata information with the target port address of the target port, and delete the target environment identifier in the metadata information to obtain the target metadata information; The target metadata information is returned to the requester, so that the requester can send the first message request to the target port based on the target port address in the target metadata information.

3. The message request processing method according to claim 2, characterized in that, The step of obtaining the second message request sent by the requester to the message server cluster based on the target port includes: The requesting party intercepts and forwards the second message request based on the target forwarding rules; The target forwarding rule refers to the forwarding rule in the forwarding rule set corresponding to the target environment that matches the destination address of the second message request; the forwarding rules in the forwarding rule set are generated based on the correspondence between the service address and the target port address.

4. The message request processing method according to claim 3, characterized in that, The method further includes: In response to the proxy activation request, a target port is selected from the idle ports, the target port is adjusted to be in working state, and the target port address of the target port is obtained; the proxy activation request includes the target environment identifier and the service address; Based on the service address and the target port address, a forwarding rule corresponding to the target environment identifier is generated, and the forwarding rule is written into the forwarding rule set of the requester. The environment port mapping information is generated based on the correspondence between the target environment identifier and the target port address.

5. The message request processing method according to claim 4, characterized in that, The method further includes: In response to a proxy shutdown request, based on the target environment identifier in the proxy shutdown request, the matching target mapping information in the environment port mapping information is determined; the target mapping information indicates the correspondence between the target environment identifier and the target port address. Based on the service address and the target port address in the proxy shutdown request, the corresponding forwarding rule is deleted from the forwarding rule set of the requester; Adjust the target port corresponding to the target port address to be in an idle state, and delete the target mapping information.

6. The message request processing method according to claim 4, characterized in that, The step of selecting a target port from idle ports in response to a proxy activation request includes: In response to the proxy activation request, detection requests are sent sequentially to ports that are in an idle state; When a response is received from any of the idle ports, the idle port is identified as the target port.

7. A message request processing apparatus, characterized in that, The device includes: The first message request acquisition module is used to acquire the first message request based on the target port; the request type of the first message request is a non-metadata request. The first environment identifier adding module is used to add a target environment identifier to the content of the first field associated with the target topic identifier in the first message request to obtain the target first message request; the target environment identifier is the environment identifier corresponding to the target port determined based on environment port mapping information, and the environment port mapping information represents the correspondence between the environment identifier and the port address; The first mapping information determination module is used to determine the matching target service address mapping information in the service address mapping information based on the target topic identifier and the target environment identifier; the service address mapping information represents the correspondence between the topic environment identifier and the service address, the topic environment identifier includes a topic identifier and an environment identifier, and the service address is the address of the message server in the message server cluster; The first sending module is used to send the target first message request based on the target service address in the target service address mapping information, and to obtain message data returned in response to the target first message request. The first data return module is used to delete the target environment identifier from the message data to obtain target message data, and return the target message data to the requester of the first message request; the business environment of the requester is the target environment corresponding to the target environment identifier.

8. A message request processing apparatus, characterized in that, The device includes: The business server is used to send a first message request to the target port of the proxy server; the request type of the first message request is a non-metadata request. A proxy server is configured to add a target environment identifier to the first field content associated with the target topic identifier in the first message request to obtain a target first message request; determine matching target service address mapping information in the service address mapping information based on the target topic identifier and the target environment identifier; and send the target first message request to the message server cluster based on the target service address in the target service address mapping information; wherein, the target environment identifier is an environment identifier corresponding to the target port determined based on the environment port mapping information, and the environment port mapping information represents the correspondence between the environment identifier and the port address; the service address mapping information represents the correspondence between the topic environment identifier and the service address, the topic environment identifier includes a topic identifier and an environment identifier, and the service address is the address of the message server in the message server cluster; A message server cluster is used to return message data to the proxy server in response to the first message request from the target. The proxy server is also used to obtain the message data; delete the target environment identifier from the message data to obtain target message data, and return the target message data to the business server.

9. The message request processing apparatus according to claim 8, characterized in that, Before sending the first message request to the target port of the proxy server, the business server is also used to intercept the second message request sent to the message server cluster based on the target forwarding rules, and forward the second message request to the target port of the proxy server; the request type of the second message request is a metadata request. The proxy server is further configured to obtain the second message request based on the target port, and add the target environment identifier to the content of the second field associated with the target topic identifier in the second message request to obtain the target second message request; The target second message request is sent to the message server cluster, and the metadata information returned by the message server cluster is obtained. The metadata information includes the address information of the message server in the message server cluster corresponding to the target topic environment identifier. Based on the address information of the message server corresponding to the target topic environment identifier, the target service address mapping information is generated. Replace the message server address information in the metadata information with the target port address of the target port, and delete the target environment identifier in the metadata information to obtain the target metadata information; The target metadata information is returned to the business server.

10. The message request processing apparatus according to claim 9, characterized in that, The proxy server is further configured to, in response to a proxy activation request, select a target port from idle ports, adjust the target port to a working state, and obtain the target port address of the target port; the proxy activation request includes the target environment identifier and the service address; generate a forwarding rule corresponding to the target environment identifier based on the service address and the target port address, and write the forwarding rule into the forwarding rule set of the business server; and generate the environment port mapping information based on the correspondence between the target environment identifier and the target port address.

11. The message request processing apparatus according to claim 10, characterized in that, The proxy server is further configured to respond to a proxy shutdown request by determining, based on the target environment identifier in the proxy shutdown request, matching target mapping information in the environment port mapping information; the target mapping information indicates the correspondence between the target environment identifier and the target port address; deleting the corresponding forwarding rule from the forwarding rule set of the business server based on the service address and the target port address in the proxy shutdown request; adjusting the target port corresponding to the target port address to be in an idle state; and deleting the target mapping information.

12. An electronic device, characterized in that, The method includes a processor and a memory, wherein the memory stores at least one instruction or at least one program, the at least one instruction or the at least one program being loaded and executed by the processor to implement the message request processing method as described in any one of claims 1 to 6.

13. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores at least one instruction or at least one program, which is loaded and executed by a processor to implement the message request processing method as described in any one of claims 1 to 6.

14. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by the processor, it implements the message request processing method according to any one of claims 1 to 6.

Citation Information

Patent Citations

  • Resource allocation method and network equipment

    CN107153565A

  • Data transmission method and device under multi-target network

    CN114125025A