Message processing method and device, computer equipment and storage medium
By building a message processor in the sidecar container and using standard interfaces to process messages between the service container and the message server, the problem of difficulty in maintaining the traditional message middleware SDK is solved, and efficient message processing and reducing maintenance difficulty is achieved.
Patent Information
- Application Number
- CN202311626596.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-11-29
- Publication Date
- 2025-05-30
AI Technical Summary
The SDK of traditional message middleware is highly coupled with business processes, resulting in increased maintenance difficulty.
By building a message processor in a sidecar container, using standard interfaces to perform message processing between the service container and the message server, the coupling between the SDK and the business process is reduced.
It realizes that while ensuring message processing capabilities, it reduces the difficulty of SDK maintenance of message middleware and improves the system's maintainability.
Smart Images

Figure CN120066809A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technologies, and particularly to a message processing method, apparatus, computer device, storage medium, and computer program product. Background Art
[0002] With the development of computer technologies, message middleware technologies have emerged. By using message middleware technologies, the message processing capabilities during application runtime can be realized.
[0003] In traditional technologies, the interfaces of message middleware are usually used to realize the message processing capabilities during application runtime.
[0004] However, in addition to some open-source standard interfaces, there are usually some custom extended interfaces among these interfaces. The standard SDKs (Software Development Kits) corresponding to these standard interfaces and the extended SDKs corresponding to the extended interfaces are both injected into the business containers corresponding to the applications for the business to call. This will lead to a relatively deep coupling degree between the SDKs of the message middleware and the business processes, bringing difficulties to the maintenance of these SDKs. Summary of the Invention
[0005] Based on this, in view of the above technical problems, it is necessary to provide a message processing method, apparatus, computer device, computer-readable storage medium, and computer program product that can reduce the maintenance difficulty of the SDKs of the message middleware.
[0006] In a first aspect, the present application provides a message processing method. The method includes:
[0007] According to the standard interfaces set in the business container, call the message logic interfaces in the sidecar container to construct a message processor in the sidecar container;
[0008] Based on the message processor, perform message processing between the business container and the message server.
[0009] In one of the embodiments, the message logic interfaces include production message logic interfaces, and the message processor includes a topic sender; the step of calling the message logic interfaces in the sidecar container to construct a message processor in the sidecar container according to the standard interfaces set in the business container includes:
[0010] Call the standard interfaces in the business container to generate a production interface call request in the business container; according to the preset port address, send the production interface call request to the sidecar container; in response to the production interface call request, call the corresponding production message logic interface in the sidecar container to construct a topic sender.
[0011] In one embodiment, a topic sender is constructed, including:
[0012] Obtain the production message topic and the target token in the production interface call request; if there is a topic configuration corresponding to the production message topic in the sidecar container, construct a topic sender according to the production client corresponding to the target token, where the topic sender is used to send the message content corresponding to the production message topic to the message server.
[0013] In one embodiment, the message logic interface includes a consumption message logic interface, and the message processor includes a topic consumer; the constructing of a message processor in the sidecar container by calling the message logic interface in the sidecar container according to the standard interface set in the service container includes:
[0014] Obtain the message subscription annotation of the message consumption thread in the service container, and generate a consumption interface call request by calling the standard interface set in the service container according to the message subscription annotation; send the consumption interface call request to the sidecar container according to the preset port address; in response to the consumption interface call request, call the corresponding consumption message logic interface in the sidecar container to construct a topic consumer, where the topic consumer is used to pull messages from the message server to the message consumption thread.
[0015] In one embodiment, constructing a topic consumer includes:
[0016] Find the corresponding consumption client in the sidecar container according to the consumption message topic and the client association parameter in the consumption interface call request; construct a topic consumer corresponding to the message consumption thread according to the consumption client.
[0017] In one embodiment, the message processing between the service container and the message server based on the message processor includes:
[0018] Use the topic consumer to pull the messages to be consumed from the message server and add the messages to be consumed to the cache queue; send the messages to be consumed to the service container through the cache queue according to the message pull request of the service container, and extract the messages to be consumed from the cache queue to the response queue; if the message reception response information of the service container is received through the sidecar container, delete the messages to be consumed in the cache queue; perform consumption processing on the messages to be consumed according to the message consumption thread in the sidecar container; if the consumption processing response information of the service container is received through the sidecar container, delete the messages to be consumed in the response queue and feedback the consumption completion information to the message server.
[0019] In one of the embodiments, the method further includes:
[0020] Obtain the sidecar configuration corresponding to the sidecar container, and inject the sidecar configuration into the corresponding sidecar container through the container platform; pull the message middleware configuration from the message middleware platform, and distribute the message middleware configuration to the corresponding sidecar container through the access machine service in terms of business services.
[0021] In a second aspect, the present application further provides a message processing device. The device includes:
[0022] A construction module for constructing a message processor in the sidecar container by calling the message logic interface in the sidecar container according to the standard interface set in the business container;
[0023] A message processing module for performing message processing between the business container and the message server based on the message processor.
[0024] In a third aspect, the present application further provides a computer device. The computer device includes a memory and a processor. The memory stores a computer program, and when the processor executes the computer program, the following steps are implemented:
[0025] Construct a message processor in the sidecar container by calling the message logic interface in the sidecar container according to the standard interface set in the business container; perform message processing between the business container and the message server based on the message processor.
[0026] In a fourth aspect, the present application further provides a computer-readable storage medium. The computer-readable storage medium stores a computer program thereon, and when the computer program is executed by a processor, the following steps are implemented:
[0027] Construct a message processor in the sidecar container by calling the message logic interface in the sidecar container according to the standard interface set in the business container; perform message processing between the business container and the message server based on the message processor.
[0028] In a fifth aspect, the present application further provides a computer program product. The computer program product includes a computer program, and when the computer program is executed by a processor, the following steps are implemented:
[0029] Construct a message processor in the sidecar container by calling the message logic interface in the sidecar container according to the standard interface set in the business container; perform message processing between the business container and the message server based on the message processor.
[0030] The above message processing method, apparatus, computer device, and storage medium can, according to the standard interfaces set in the service container, call the message logic interfaces in the sidecar container through the standard interfaces to construct a message processor in the sidecar container. Thus, based on the message processor, message processing can be performed between the service container and the message server. In this way, only some standard interfaces are set in the service container, and these interfaces are only used to initiate access to the sidecar container, while the message logic interfaces for executing specific message logics are all sunk in the sidecar container. Therefore, only the SDKs of some standard interfaces are deployed in the service container, and the SDKs corresponding to the message logic interfaces specifically used to implement the message processing logic are deployed in the sidecar container. Therefore, while ensuring the message processing ability during application runtime, the SDKs of the message middleware can be decoupled from the business process, thereby reducing the maintenance difficulty of the SDKs of the message middleware. Description of the Drawings
[0031] Figure 1 It is a schematic flowchart of the message processing method in an embodiment;
[0032] Figure 2 It is a visual schematic diagram of the sinking of the message processing ability of the service container to the sidecar container when the application starts in an embodiment;
[0033] Figure 3 It is a schematic flowchart of constructing a message processor in the sidecar container in an embodiment;
[0034] Figure 4 It is a schematic flowchart of constructing a message processor in the sidecar container in another embodiment;
[0035] Figure 5 It is a visual flowchart of message processing between the service container and the message server in an embodiment;
[0036] Figure 6 It is a visual flowchart of setting the sidecar container configuration in an embodiment;
[0037] Figure 7 It is a structural block diagram of the message processing apparatus in an embodiment;
[0038] Figure 8 It is an internal structure diagram of a computer device in an embodiment. Detailed Embodiments
[0039] In order to make the objectives, technical solutions, and advantages of the present application clearer, the present application will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0040] In one embodiment, asFigure 1 As shown in Figure 1 , a message processing method is provided. In this embodiment, taking the application of this method to a terminal as an example, it can be understood that this method can also be applied to a server, or to a system including a terminal and a server, and is implemented through the interaction between the terminal and the server. In this embodiment, the method includes the following steps:
[0041] Step 202: According to the standard interface set in the service container, call the message logic interface in the sidecar container to construct a message processor in the sidecar container.
[0042] Among them, the service container is a container that bears service logic code, and the sidecar container is an accompanying container of the service container, which is used to bear the message middleware logic code corresponding to the service logic code and can implement the message processing capability during application operation; the message processor is used to implement the message processing capability during application operation, such as the ability to produce messages or consume messages, etc.
[0043] It should be noted that a standard interface is set in the service container. The standard interface is a call interface for the service container to call the message logic interface in the sidecar container. And since the standard interface is an open-source standard interface, it is easy to maintain; a message logic interface is set in the sidecar container, and this message logic interface is used to implement the message processing logic. By calling this message logic interface, a corresponding message processor can be constructed to implement the message processing logic.
[0044] As an example, step 202 includes: calling the standard interface in the service container to generate an interface call request; by sending the interface call request to the sidecar container, calling the message logic interface in the sidecar container, and constructing a message processor in the sidecar container according to this message logic interface.
[0045] Step 204: Based on the message processor, perform message processing between the service container and the message server.
[0046] Among them, the message processor includes a message production logic interface and a message consumption logic interface. The message production logic interface is used to transmit the messages produced by the service container to the message server, and the message consumption logic interface is used to pull messages from the message server into the service container for consumption.
[0047] As an example, step 204 includes: based on the message production processor, transmitting the messages produced by the service container to the message server.
[0048] As an example, step 204 includes: based on the message consumption processor, pulling the messages to be consumed from the message server and pushing the messages to be consumed into the service container for consumption.
[0049] As an example, the standard interface can be the Pulsar standard interface, and the message logic interface can be the Pulsar extension interface.
[0050] As an example, the message middleware can be a Pulsar component. Refer to Figure 2 , Figure 2 Fig. Figure 2 is a visualization diagram of sinking the message processing capability of the business container to the sidecar container when the application starts. Here, pod is a container, and the pod includes a business process and a sidecar process. Since the business process and the sidecar process are two different processes, it can also be considered that the total container includes a business container and a sidecar container. The business container carries the business process, and the sidecar container carries the sidecar process. The standard SDK package is the standard SDK package of the Pulsar component, which includes the pulsar api (standard interface) and grpc (interface call request module). Layotto is the data plane, and the custom plugin is a custom plugin that includes some custom pulsar clients (Pulsar clients). The Pulsar server is the message server. In this way, when the outside requests the business method of the business process through the service interface, the business process will generate a grpc call request through the pulsar api to access the sidecar process, and call the message logic interface of the sidecar process to select the corresponding custom pulsar client to construct a message processor, and interact with the Pulsar server (message server) through the message processor to implement the message processing process.
[0051] In the above message processing method, according to the standard interface set in the business container, the message logic interface in the sidecar container can be called through the standard interface to construct a message processor in the sidecar container. Thus, based on the message processor, message processing can be performed between the business container and the message server. In this way, only some standard interfaces are set in the business container, and these interfaces are only used to initiate access to the sidecar container. However, the message logic interfaces for executing specific message logics are all sunk in the sidecar container. Therefore, only the SDKs of some standard interfaces are deployed in the business container, and the SDKs corresponding to the message logic interfaces for specifically implementing the message processing logic are deployed in the sidecar container. Therefore, while ensuring the realization of the message processing capability during the application runtime, the SDK of the message middleware can be decoupled from the business process, thereby reducing the maintenance difficulty of the SDK of the message middleware.
[0052] In one embodiment, as shown in Figure 3 , the message logic interface includes a production message logic interface, and the message processor includes a topic sender; calling the message logic interface in the sidecar container to construct a message processor in the sidecar container according to the standard interface set in the business container includes:
[0053] Step 302: Invoke the standard interface in the business container to generate a production interface call request in the business container.
[0054] Among them, the production interface call request includes message production parameters, which are used to pass the message production parameters to the sidecar container. The message production parameters may include a message topic, message content, etc.
[0055] As an example, step 302 includes: Invoke the standard interface in the business container to encapsulate the message production parameters generated by the business process in the business container into a production interface call request. Among them, the production interface call request may be a grpc call request.
[0056] Step 304: Send the production interface call request to the sidecar container according to the preset port address.
[0057] Among them, the preset port address is the service port address of the sidecar process in the sidecar container. In this embodiment, by fixing the request address of the production interface call request to the preset port address, it can be ensured that the production interface call request can be accurately sent to the sidecar process.
[0058] Step 306: In response to the production interface call request, invoke the corresponding production message logic interface in the sidecar container to construct a topic sender.
[0059] As an example, step 306 includes: By parsing the production interface call request, in the sidecar container, a topic sender is constructed by invoking the corresponding production message logic interface. Among them, the topic sender is used to transmit the message content in the production interface call request to the message server.
[0060] As an example, the generated message logic interface may be a pulsar service interface set in the sidecar container, which is used to invoke the corresponding production client to construct a topic sender.
[0061] In one embodiment, constructing a topic sender includes:
[0062] Obtain the production message topic and the target token in the production interface call request; if there is a topic configuration corresponding to the production message topic in the sidecar container, construct a topic sender according to the production client corresponding to the target token, where the topic sender is used to send the message content corresponding to the production message topic to the message server.
[0063] Specifically, parse the production interface call request to obtain the production message topic and the target token; if the topic configuration corresponding to the production message topic does not exist in the sidecar container, return an error message to the business container, where the topic configuration is the configuration information used to construct the topic sender; if the topic configuration corresponding to the production message topic exists in the sidecar container, call the production client corresponding to the target token to construct a topic sender for the message production request, where the topic sender is used to send the message content corresponding to the production message topic to the message server.
[0064] As an example, the production client can be a custom plug-in for constructing a topic sender.
[0065] In this embodiment, a production interface call request can be generated in the business container by calling a standard interface in the business container; then, according to the preset port address, the production interface call request is accurately sent to the sidecar container, and the sidecar container responds to the production interface call request and calls the corresponding production message logic interface to construct a topic sender. In this way, the standard interface in the business container is only a simple standard interface for generating call requests, rather than a complex custom extension interface. The production message logic interface, as a complex custom extension interface, is deployed in the sidecar container. Therefore, the coupling degree between the business logic and the message processing logic during the production message process is relatively low, laying a foundation for reducing the maintenance difficulty of the SDK of the message processing logic.
[0066] In one embodiment, as Figure 4 shown, the message logic interface includes a consume message logic interface, and the message processor includes a topic consumer; according to the standard interface set in the business container, calling the message logic interface in the sidecar container to construct a message processor in the sidecar container includes:
[0067] Step 402, obtain the message subscription annotation of the message consumption thread in the business container, and according to the message subscription annotation, call the standard interface set in the business container to generate a consume interface call request.
[0068] Among them, the message consumption thread can be a thread in the business process that consumes messages in the business container, used to consume the pulled messages to ensure the normal operation of the business process. The message consumption thread is set with a message subscription annotation, and the message subscription annotation includes a consume message topic and a client association parameter, and the client association parameter is used to query the corresponding consume client, specifically, it can be the identification information of the consume group and the consume cluster.
[0069] As an example, step 402 includes: obtaining the message subscription annotation of the message consumption thread in the business container; calling the standard interface in the business container to encapsulate the message subscription annotation into a consume interface call request, where the consume interface call request can be a grpc call request.
[0070] Step 404: Send the consumption interface call request to the sidecar container according to the preset port address.
[0071] Wherein, the preset port address is the service port address of the sidecar process in the sidecar container. In this embodiment, by fixing the request address of the consumption interface call request to the preset port address, it can be ensured that the consumption interface call request can be accurately sent to the sidecar process.
[0072] Step 406: In response to the consumption interface call request, call the corresponding consumption message logic interface in the sidecar container to construct a topic consumer, where the topic consumer is used to pull messages from the message server to the message consumption thread.
[0073] As an example, step 406 includes: By parsing the consumption interface call request, call the corresponding consumption message logic interface in the sidecar container to construct a topic consumer, where the topic consumer is used to pull the messages to be consumed from the message server and transmit the messages to be consumed to the message consumption thread of the service container for consumption.
[0074] As an example, the message logic interface can be the pulsar service interface set in the sidecar container, which is used to call the corresponding consumption client to construct a topic consumer.
[0075] In one embodiment, constructing the topic consumer includes:
[0076] Find the corresponding consumption client in the sidecar container according to the consumption message topic and client association parameters in the consumption interface call request; construct the topic consumer corresponding to the message consumption thread according to the consumption client.
[0077] Specifically, parse the consumption interface call request to obtain the consumption message topic and client association parameters, where the client association parameters include the consumption group identifier and the consumption cluster identifier; find the corresponding consumption client in the sidecar container according to the consumption message topic, consumption group identifier and consumption cluster identifier; use the found consumption client to construct the corresponding topic consumer.
[0078] As an example, the consumption client can be a custom plug-in used to construct a topic consumer, and the topic consumer has a message pulling function and can pull messages from the message server.
[0079] In the above embodiments, a standard interface is set in the service container. After the service consumption thread is started, the standard interface can be called to encapsulate the message subscription annotation of the message consumption thread into a consumption interface call request. Then, according to the preset port address, the consumption interface call request is accurately sent to the sidecar container. In response to the consumption interface call request, the sidecar container can call the corresponding consumption message logic interface to construct a topic consumer. Thus, the standard interface in the service container is only a simple standard interface for generating call requests, rather than a complex custom extension interface. The consumption message logic interface, which is a complex custom extension interface, is deployed in the sidecar container. Therefore, the coupling degree between the service logic and the message processing logic during the message consumption process is relatively low, laying a foundation for reducing the maintenance difficulty of the SDK for the message processing logic.
[0080] In one embodiment, based on the message processor, message processing is performed between the service container and the message server, including:
[0081] Using the topic consumer, pull the messages to be consumed from the message server and add the messages to the cache queue. According to the message pull request of the service container, send the messages to be consumed to the service container through the cache queue, and extract the messages to be consumed from the cache queue to the response queue. If the message reception response information of the service container is received through the sidecar container, delete the messages to be consumed in the cache queue. According to the message consumption thread in the sidecar container, perform consumption processing on the messages to be consumed. If the consumption processing response information of the service container is received by the sidecar container, delete the messages to be consumed in the response queue and feedback the consumption completion information to the message server.
[0082] Among them, a cache queue and a response queue are set in the sidecar container. The cache queue is used to cache the messages to be consumed pulled by the topic consumer from the message server, and the response queue is used to transmit the messages to be consumed to the service container. After successfully constructing the consumption topic consumer, the sidecar container will notify the service container that the subscription is successful, and the consumption topic consumer will start continuously pulling the messages to be consumed from the consumption server.
[0083] Specifically, use the topic consumer to pull the messages to be consumed from the message server and add the messages to be consumed to the cache queue; if a message pull request from the service container is received, send the messages to be consumed to the service container through the cache queue, and add the sent messages to be consumed and the request identifier of the message pull request to the response queue; use the topic consumer to pull the messages to be consumed from the message server and add the messages to be consumed to the cache queue; after the service container receives the messages to be consumed, feedback message reception response information to the sidecar container through the service container, where the message reception response information is used to indicate that the service container has received the messages to be consumed; add the messages to be consumed to the queue to be processed in the service container and wait for the message consumption thread to consume the messages to be consumed; if the sidecar container receives the message reception response information from the service container, delete the messages to be consumed corresponding to the message reception response information in the cache queue.
[0084] Furthermore, start the message distribution thread, distribute the messages to be consumed in the queue to be processed to the message consumption thread for consumption processing through the message distribution thread, and add the messages to be consumed after the consumption processing is completed to the processed queue; obtain the messages to be consumed after the message processing is completed in the processed queue through the message completion queue, generate consumption processing response information corresponding to the messages to be consumed after the message processing is completed, and feedback the consumption processing response information to the sidecar container; if the sidecar container receives the consumption processing response information fed back by the service container, where the consumption processing response information is used to indicate that the service container has processed (consumed) the messages to be consumed, and the consumption processing response information may include the request identifier of the message pull request, then delete the request identifier and the messages to be consumed corresponding to the request identifier in the response queue according to the request identifier, and feedback consumption completion information to the consumption server, where the consumption completion information is used to notify the message server that the messages to be consumed pulled have been consumed.
[0085] As Figure 5 shown, Figure 5 FIG. is a visual flowchart of message processing between the service container and the message server in an embodiment, where the responded information is the consumption processing response information, which is used to indicate that the message consumption thread has consumed the pulled messages to be consumed, and the response queue information is the request identifier and the messages to be consumed corresponding to the request identifier.
[0086] In the above embodiments, by setting a to-be-processed queue and a processed queue in the service container, it can be ensured that after the messages to be consumed enter the service container, the message consumption threads in the service container can consume the messages to be consumed in an orderly manner, and feedback message reception response information to the sidecar container when receiving the messages to be consumed, and feedback message processing response information to the sidecar container after the messages to be consumed are consumed. In the sidecar container, a cache queue and a response queue are set. Through the cache queue, the pulled messages to be consumed can be sent to the service container in an orderly manner. And after receiving the message reception response information, the corresponding message to be consumed can be deleted in the cache queue to record whether each message to be consumed has been received by the service container, so as to ensure the orderly progress of message consumption. In addition, after receiving the message processing response information, the corresponding message to be consumed will be deleted in the response queue to record whether each message to be consumed has been consumed and processed in the service container, so as to further ensure the orderly progress of message consumption. Therefore, in this embodiment, by setting a to-be-processed queue and a processed queue in the service container, and a cache queue and a response queue in the sidecar container, it can be ensured that the entire message consumption process is processed in a flowing water manner in an orderly manner, and the message consumption process can be realized orderly on the basis of sinking the message middleware logic to the sidecar container.
[0087] In one embodiment, to construct a topic consumer, the message processing method further includes:
[0088] Obtain the sidecar configuration corresponding to the sidecar container, and inject the sidecar configuration into the corresponding sidecar container through the container platform; pull the message middleware configuration from the message middleware platform, and distribute the message middleware configuration to the corresponding sidecar container through the access machine service in terms of business services.
[0089] Among them, for the original sidecar configuration of the sidecar container, each sidecar container is basically the same. Therefore, the sidecar configuration can be directly injected into the corresponding sidecar container through the container platform; for the customized message middleware configuration, the message middleware configurations of different services are usually different. Therefore, it is necessary to distribute the message middleware configuration to the sidecar container in terms of services. In this way, the message middleware configuration can be distributed with an appropriate granularity, and the changes in the message middleware configurations between different services will not affect each other, and the frequency of the message middleware configuration of the sidecar containers of different business containers can be reduced.
[0090] As Figure 6 shown, Figure 6It is a visual flowchart for setting the sidecar container configuration in an embodiment. Here, Pod-A is the business container, and Pod-B is the sidecar container. Users (developers, testers, or operation and maintenance personnel) can issue a sidecar access instruction through the sidecar management module of the cloud-native platform. Then, the sidecar management module interacts with the governance platform to construct the sidecar access configuration. After that, the governance platform can inject the sidecar configuration into the sidecar container (Pod-B) by namespace through the container platform. Users (developers, testers, or operation and maintenance personnel) can also set the message middleware configuration through the cloud-native platform. The runtime service of the cloud-native platform can pull the configuration verification information from the message middleware platform to verify the message middleware configuration. After passing the verification, the message middleware configuration is directly issued to the pulsar component in the sidecar container by the access machine service of the cloud-native platform at the granularity of the business service.
[0091] In an embodiment, the standard interface in the business container is called, and the message information to be processed is encapsulated as an interface call request in the business container. Here, the message information to be processed can be the message production parameters generated by the business process in the business container or the message subscription annotation of the message consumption thread. The interface call request is sent to the sidecar container through the preset port address. By parsing the interface call request, the corresponding message logic interface is called in the sidecar container to construct a topic message handler. If the message logic interface is a message production logic interface, the topic message handler is a topic sender. If the message logic interface is a message consumption logic interface, the topic message handler is a topic consumer. Based on the message processor, message processing is performed between the business container and the message server.
[0092] In the above embodiment, only some standard interfaces are set in the business container. These interfaces are only used to initiate access to the sidecar container, while the message logic interfaces for executing specific message logics are all sunk in the sidecar container. Therefore, only the SDKs of some standard interfaces are deployed in the business container, and the SDKs corresponding to the other message logic interfaces specifically for implementing the message processing logic are deployed in the sidecar container. Thus, while ensuring the message processing ability during application runtime, the SDK of the message middleware can be decoupled from the business process, thereby reducing the maintenance difficulty of the SDK of the message middleware.
[0093] It should be understood that although the steps in the flowcharts involved in the above-described embodiments are sequentially shown according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless there is a clear indication in this article, the execution of these steps has no strict order limit, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above-described embodiments may include multiple steps or multiple stages. These steps or stages are not necessarily executed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be executed alternately or in turn with at least a part of other steps or steps or stages in other steps.
[0094] Based on the same inventive concept, an embodiment of the present application further provides a message processing device for implementing the message processing method involved above. The solution provided by this device to solve the problem is similar to the solution described in the above method. Therefore, the specific limitations in one or more embodiments of the message processing device provided below can refer to the limitations on the message processing method in the above text, and will not be repeated here.
[0095] In one embodiment, as Figure 7 shown, a message processing device is provided, including: a construction module 502 and a message processing module 504, where:
[0096] The construction module is used to call the message logic interface in the sidecar container to construct a message processor in the sidecar container according to the standard interface set in the service container.
[0097] The message processing module is used to perform message processing between the service container and the message server based on the message processor.
[0098] In one of the embodiments, the message logic interface includes a production message logic interface, and the message processor includes a topic sender; the construction module is further used to:
[0099] Call the standard interface in the service container to generate a production interface call request in the service container; send the production interface call request to the sidecar container according to the preset port address; in response to the production interface call request, call the corresponding production message logic interface in the sidecar container to construct a topic sender.
[0100] In one of the embodiments, the construction module is further used to:
[0101] Obtain the production message topic and the target token in the production interface call request; if there is a topic configuration corresponding to the production message topic in the sidecar container, construct a topic sender according to the production client corresponding to the target token, where the topic sender is used to send the message content corresponding to the production message topic to the message server.
[0102] In one embodiment, the message logic interface includes a consumption message logic interface, and the message processor includes a topic consumer; the construction module is further configured to:
[0103] Obtain the message subscription annotation of the message consumption thread in the service container, and according to the message subscription annotation, call the standard interface set in the service container to generate a consumption interface call request; send the consumption interface call request to the sidecar container according to the preset port address; in response to the consumption interface call request, call the corresponding consumption message logic interface in the sidecar container to construct a topic consumer, where the topic consumer is used to pull messages from the message server to the message consumption thread.
[0104] In one embodiment, the construction module is further configured to:
[0105] Find the corresponding consumption client in the sidecar container according to the consumption message topic and the client association parameter in the consumption interface call request; construct a topic consumer corresponding to the message consumption thread according to the consumption client.
[0106] In one embodiment, the message processing module is further configured to:
[0107] Use the topic consumer to pull the messages to be consumed from the message server, and add the messages to the cache queue; according to the message pull request of the service container, send the messages to be consumed to the service container through the cache queue, and extract the messages to be consumed from the cache queue to the response queue; if the message reception response information of the service container is received through the sidecar container, delete the messages to be consumed in the cache queue; perform consumption processing on the messages to be consumed according to the message consumption thread in the sidecar container; if the consumption processing response information of the service container is received through the sidecar container, delete the messages to be consumed in the response queue, and feedback consumption completion information to the message server.
[0108] In one embodiment, the message processing device further includes:
[0109] A configuration distribution module, configured to obtain a sidecar configuration corresponding to a sidecar container, and inject the sidecar configuration into the corresponding sidecar container through a container platform; pull a message middleware configuration from a message middleware platform, and distribute the message middleware configuration to the corresponding sidecar container through an access machine service in terms of business services.
[0110] Each module in the above message processing device can be implemented in whole or in part by software, hardware, and their combination. The above modules can be embedded in the processor in the computer device in hardware form or be independent of the processor, or be stored in the memory in the computer device in software form, so that the processor can call and execute the operations corresponding to the above respective modules.
[0111] In one embodiment, a computer device is provided. The computer device can be a server, and its internal structure diagram can be as Figure 8 shown. The computer device includes a processor, a memory, and a network interface connected through a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program, and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store message processing data. The network interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, it implements a message processing method.
[0112] Those skilled in the art can understand that Figure 8 the structure shown in
[0113] is only a block diagram of a part of the structure related to the solution of this application, and does not constitute a limitation on the computer device to which the solution of this application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.
[0114] According to a standard interface set in a business container, call a message logic interface in a sidecar container to construct a message processor in the sidecar container; based on the message processor, perform message processing between the business container and a message server.
[0115] In one embodiment, the message logic interface includes a production message logic interface, and the message processor includes a topic sender; when the processor executes the computer program, the following steps are further implemented:
[0116] Call the standard interface in the service container to generate a production interface call request in the service container; according to the preset port address, send the production interface call request to the sidecar container; in response to the production interface call request, call the corresponding production message logic interface in the sidecar container to construct a topic sender.
[0117] In one embodiment, when the processor executes the computer program, the following steps are further implemented:
[0118] Obtain the production message topic and the target token in the production interface call request; if there is a topic configuration corresponding to the production message topic in the sidecar container, construct a topic sender according to the production client corresponding to the target token, where the topic sender is used to send the message content corresponding to the production message topic to the message server.
[0119] In one embodiment, the message logic interface includes a consume message logic interface, and the message processor includes a topic consumer; when the processor executes the computer program, the following steps are further implemented:
[0120] Obtain the message subscription annotation of the message consumption thread in the service container, and according to the message subscription annotation, call the standard interface set in the service container to generate a consume interface call request; according to the preset port address, send the consume interface call request to the sidecar container; in response to the consume interface call request, call the corresponding consume message logic interface in the sidecar container to construct a topic consumer, where the topic consumer is used to pull messages from the message server to the message consumption thread.
[0121] In one embodiment, when the processor executes the computer program, the following steps are further implemented:
[0122] Find the corresponding consume client in the sidecar container according to the consume message topic and the client association parameter in the consume interface call request; construct the topic consumer corresponding to the message consumption thread according to the consume client.
[0123] In one embodiment, when the processor executes the computer program, the following steps are further implemented:
[0124] Using the subject consumer, pull the messages to be consumed from the message server and add the messages to be consumed to the cache queue; according to the message pull request of the service container, send the messages to be consumed to the service container through the cache queue, and extract the messages to be consumed from the cache queue to the response queue; if the message reception response information of the service container is received through the sidecar container, delete the messages to be consumed in the cache queue; according to the message consumption thread in the sidecar container, perform consumption processing on the messages to be consumed; if the consumption processing response information of the service container is received through the sidecar container, delete the messages to be consumed in the response queue and feedback consumption completion information to the message server.
[0125] In one embodiment, when the processor executes the computer program, the following steps are further implemented:
[0126] Obtain the sidecar configuration corresponding to the sidecar container, and inject the sidecar configuration into the corresponding sidecar container through the container platform; pull the message middleware configuration from the message middleware platform, and issue the message middleware configuration to the corresponding sidecar container through the access machine service in terms of business services.
[0127] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the following steps are implemented:
[0128] According to the standard interface set in the service container, call the message logic interface in the sidecar container to construct a message processor in the sidecar container; based on the message processor, perform message processing between the service container and the message server.
[0129] In one embodiment, the message logic interface includes a production message logic interface, and the message processor includes a topic sender; when the computer program is executed by a processor, the following steps are further implemented:
[0130] Call the standard interface in the service container to generate a production interface call request in the service container; according to the preset port address, send the production interface call request to the sidecar container; in response to the production interface call request, call the corresponding production message logic interface in the sidecar container to construct a topic sender.
[0131] In one embodiment, when the computer program is executed by a processor, the following steps are further implemented:
[0132] Obtain the production message topic and the target token in the production interface call request; if there is a topic configuration corresponding to the production message topic in the sidecar container, construct a topic sender according to the production client corresponding to the target token, where the topic sender is used to send the message content corresponding to the production message topic to the message server.
[0133] In one embodiment, the message logic interface includes a consumption message logic interface, and the message processor includes a topic consumer; when the computer program is executed by a processor, the following steps are further implemented:
[0134] Obtain the message subscription annotation of the message consumption thread in the service container, and according to the message subscription annotation, call the standard interface set in the service container to generate a consumption interface call request; send the consumption interface call request to the sidecar container according to the preset port address; in response to the consumption interface call request, call the corresponding consumption message logic interface in the sidecar container to construct a topic consumer, where the topic consumer is used to pull messages from the message server to the message consumption thread.
[0135] In one embodiment, when the computer program is executed by a processor, the following steps are further implemented:
[0136] Find the corresponding consumption client in the sidecar container according to the consumption message topic and the client association parameter in the consumption interface call request; construct a topic consumer corresponding to the message consumption thread according to the consumption client.
[0137] In one embodiment, when the computer program is executed by a processor, the following steps are further implemented:
[0138] Use the topic consumer to pull the messages to be consumed from the message server, and add the messages to the cache queue; according to the message pull request of the service container, send the messages to be consumed to the service container through the cache queue, and extract the messages to be consumed from the cache queue to the response queue; if the message reception response information of the service container is received through the sidecar container, delete the messages to be consumed in the cache queue; perform consumption processing on the messages to be consumed according to the message consumption thread in the sidecar container; if the consumption processing response information of the service container is received through the sidecar container, delete the messages to be consumed in the response queue, and feedback consumption completion information to the message server.
[0139] In one embodiment, when the computer program is executed by a processor, the following steps are further implemented:
[0140] Obtain the sidecar configuration corresponding to the sidecar container, and inject the sidecar configuration into the corresponding sidecar container through the container platform; Pull the message middleware configuration from the message middleware platform, and distribute the message middleware configuration to the corresponding sidecar container through the access machine service by taking the business service as the granularity.
[0141] In one embodiment, a computer program product is provided, including a computer program, which when executed by a processor implements the following steps:
[0142] According to the standard interface set in the business container, call the message logic interface in the sidecar container to construct a message processor in the sidecar container; Based on the message processor, perform message processing between the business container and the message server.
[0143] In one embodiment, the message logic interface includes a production message logic interface, and the message processor includes a topic sender; When the computer program is executed by a processor, it also implements the following steps:
[0144] Call the standard interface in the business container to generate a production interface call request in the business container; According to the preset port address, send the production interface call request to the sidecar container; In response to the production interface call request, call the corresponding production message logic interface in the sidecar container to construct a topic sender.
[0145] In one embodiment, when the computer program is executed by a processor, it also implements the following steps:
[0146] Obtain the production message topic and the target token in the production interface call request; If there is a topic configuration corresponding to the production message topic in the sidecar container, construct a topic sender according to the production client corresponding to the target token, where the topic sender is used to send the message content corresponding to the production message topic to the message server.
[0147] In one embodiment, the message logic interface includes a consumption message logic interface, and the message processor includes a topic consumer; When the computer program is executed by a processor, it also implements the following steps:
[0148] Obtain the message subscription annotation of the message consumption thread in the business container, and according to the message subscription annotation, call the standard interface set in the business container to generate a consumption interface call request; According to the preset port address, send the consumption interface call request to the sidecar container; In response to the consumption interface call request, call the corresponding consumption message logic interface in the sidecar container to construct a topic consumer, where the topic consumer is used to pull messages from the message server to the message consumption thread.
[0149] In one embodiment, when the computer program is executed by a processor, the following steps are further implemented:
[0150] According to the consumption message topic and the client association parameters in the consumption interface call request, find the corresponding consumption client in the sidecar container; construct a topic consumer corresponding to the message consumption thread according to the consumption client.
[0151] In one embodiment, when the computer program is executed by a processor, the following steps are further implemented:
[0152] Use the topic consumer to pull the messages to be consumed from the message server and add the messages to the cache queue; according to the message pull request of the service container, send the messages to be consumed to the service container through the cache queue, and extract the messages to be consumed from the cache queue to the response queue; if the message reception response information of the service container is received through the sidecar container, delete the messages to be consumed in the cache queue; perform consumption processing on the messages to be consumed according to the message consumption thread in the sidecar container; if the consumption processing response information of the service container is received through the sidecar container, delete the messages to be consumed in the response queue and feedback consumption completion information to the message server.
[0153] In one embodiment, when the computer program is executed by a processor, the following steps are further implemented:
[0154] Obtain the sidecar configuration corresponding to the sidecar container and inject the sidecar configuration into the corresponding sidecar container through the container platform; pull the message middleware configuration from the message middleware platform and, with the business service as the granularity, send the message middleware configuration to the corresponding sidecar container through the access machine service.
[0155] Those of ordinary skill in the art can understand that all or part of the processes in the methods of the above embodiments can be completed by instructing relevant hardware through a computer program. The computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above methods. Among them, any reference to a memory, database, or other medium used in the embodiments provided in the present application can include at least one of non-volatile and volatile memories. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetoresistive random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM), etc. The databases involved in the embodiments provided in the present application can include at least one of relational databases and non-relational databases. Non-relational databases can include distributed databases based on blockchain, etc., without limitation. The processors involved in the embodiments provided in the present application can be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, data processing logics based on quantum computing, etc., without limitation.
[0156] The technical features of the above embodiments can be combined arbitrarily. For the sake of brevity of description, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, it should be considered as the scope described in this specification.
[0157] The above-described embodiments merely represent several implementation manners of the present application. The description is relatively specific and detailed, but it should not be construed as a limitation on the patent scope of the present application. It should be noted that for those of ordinary skill in the art, without departing from the concept of the present application, several modifications and improvements can still be made, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application should be subject to the appended claims.
Claims
1. A message processing method, characterized in that, the method includes: According to the standard interface set in the service container, call the message logic interface in the sidecar container to construct a message processor in the sidecar container; Based on the message processor, perform message processing between the service container and the message server.
2. The method according to claim 1, characterized in that, the message logic interface includes a production message logic interface, and the message processor includes a topic sender; the step of calling the message logic interface in the sidecar container according to the standard interface set in the service container to construct a message processor in the sidecar container includes: Call the standard interface in the service container to generate a production interface call request in the service container; According to the preset port address, send the production interface call request to the sidecar container; In response to the production interface call request, call the corresponding production message logic interface in the sidecar container to construct a topic sender.
3. The method according to claim 2, characterized in that, Constructing a topic sender includes: Obtain the production message topic and target token in the production interface call request; If there is a topic configuration corresponding to the production message topic in the sidecar container, construct a topic sender according to the production client corresponding to the target token, wherein the topic sender is used to send the message content corresponding to the production message topic to the message server.
4. The method according to claim 1, characterized in that, the message logic interface includes a consumption message logic interface, and the message processor includes a topic consumer; the step of calling the message logic interface in the sidecar container according to the standard interface set in the service container to construct a message processor in the sidecar container includes: Obtain the message subscription annotation of the message consumption thread in the service container, and according to the message subscription annotation, call the standard interface set in the service container to generate a consumption interface call request; According to the preset port address, send the consumption interface call request to the sidecar container; In response to the consumption interface call request, call the corresponding consumption message logic interface in the sidecar container to construct a topic consumer, wherein the topic consumer is used to pull messages from the message server to the message consumption thread.
5. The method according to claim 4, characterized in that, Constructing a topic consumer includes: According to the consumption message topic and client association parameters in the consumption interface call request, find the corresponding consumption client in the sidecar container; Construct a topic consumer corresponding to the message consumption thread according to the consumption client.
6. The method according to claim 4, characterized in that, The step of performing message processing between the service container and the message server based on the message processor includes: Use the topic consumer to pull the messages to be consumed from the message server and add the messages to be consumed to the cache queue; According to the message pull request of the service container, send the messages to be consumed to the service container through the cache queue, and extract the messages to be consumed from the cache queue to the response queue; If the message reception response information of the service container is received through the sidecar container, the message to be consumed is deleted from the buffer queue; According to the message consumption thread in the sidecar container, the message to be consumed is processed for consumption; If the consumption processing response information of the service container is received through the sidecar container, the message to be consumed in the response queue is deleted, and the consumption completion information is fed back to the message server.
7. The method according to claim 1, wherein, the method further includes: obtaining the sidecar configuration corresponding to the sidecar container, and injecting the sidecar configuration into the corresponding sidecar container through the container platform; pulling the message middleware configuration from the message middleware platform, and distributing the message middleware configuration to the corresponding sidecar container through the access machine service in terms of business services.
8. A message processing device, wherein, the device includes: a construction module, configured to call the message logic interface in the sidecar container to construct a message processor in the sidecar container according to the standard interface set in the service container; a message processing module, configured to perform message processing between the service container and the message server based on the message processor.
9. A computer device, including a memory and a processor, the memory storing a computer program, wherein, when the processor executes the computer program, the steps of the method according to any one of claims 1 to 7 are implemented.
10. A computer-readable storage medium, having a computer program stored thereon, wherein, when the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.