MNS-based message rapid integration method, apparatus and device, and storage medium

By simplifying configuration and annotation methods, the rapid integration of MNS and Spring Boot framework is achieved, which solves the complexity and stability problems in the integration process, improves development efficiency and system performance, and adapts to the diversified needs of enterprise-level applications.

CN120256160APending Publication Date: 2025-07-04SHENZHEN DIDATRAVEL TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510219379.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-02-26
Publication Date
2025-07-04

AI Technical Summary

Technical Problem

In the process of integrating Alibaba Cloud's lightweight message queue (MNS) with the Spring Boot framework, there are problems such as complex dependency management and configuration, high development difficulty, insufficient flexibility, insufficient system stability and performance optimization, which is difficult to meet the diversified needs of enterprise-level applications.

Method used

A fast message integration method based on MNS is provided, which obtains configuration parameters by scanning the configuration file of the target application, establishes a connection instance with the MNS service, identifies the message processing method using preset message annotation parameters, creates an MNS message listener instance, and listens to the message queue through the listener instance for processing.

Benefits of technology

Significantly improve development efficiency, simplify configuration processes, enhance system stability and reliability, optimize performance, provide flexible configuration management, and adapt to stable operation under different business needs and high load conditions.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120256160A_ABST
    Figure CN120256160A_ABST
Patent Text Reader

Abstract

The invention relates to an MNS-based message rapid integration method, which comprises the following steps: when a target application is detected to be started, acquiring configuration parameters related to an MNS by scanning a configuration file of the target application; establishing a connection instance with the MNS service based on the configuration parameters related to the MNS; a factory is connected based on an MNS client, and a message system client instance is established; acquiring a preset message annotation parameter; identifying a message processing method of the target application by using a preset message annotation parameter; in response to the fact that the message processing method is identified by the message annotation parameter, creating an MNS message monitor instance for the message processing method; monitoring a message queue corresponding to the message processing method through the MNS message monitor instance; and when it is monitored that a message object arrives at the message queue, sending the message object to a message processing method for processing. According to the method, the integration and development process of the message system can be simplified, and the reliability, performance and flexibility of message processing are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular, to a method, device, equipment and storage medium for rapid message integration based on MNS. Background Art

[0002] In the current era of rapid digital development, the complexity and scale of software systems are constantly increasing, and the demand for real-time, accurate and efficient message passing is becoming more and more urgent. The Spring Boot framework, with its simple and efficient development features, has been widely used in many enterprise-level applications. However, in the process of integrating Alibaba Cloud lightweight message queue (Message Notification Service, abbreviated as MNS) with the Spring Boot framework, developers often face many challenges. For example, traditional message processing integration methods usually have the following problems: a. The dependency management and configuration process is cumbersome and complex, requiring developers to have in-depth understanding of various technical details, which is error-prone and time-consuming; b. The coding of message consumption and production logic is not intuitive enough, increasing the development difficulty and maintenance cost; c. Lack of flexible configuration options and parameter adjustment mechanisms, making it difficult to meet the diverse needs of different business scenarios and performance requirements; d. Existing solutions also have many deficiencies in system scalability, stability and performance optimization, and cannot adapt to the increasing business complexity and the pressure of high-concurrency access.

[0003] Therefore, it is necessary to propose a method, device, equipment and storage medium for rapid message integration based on MNS. Summary of the Invention

[0004] The present application provides a method, device and storage medium for rapid message integration based on MNS, aiming to provide a simple, efficient, flexible and easy-to-expand message processing integration method, which can significantly improve development efficiency, reduce development costs, and ensure the stability and performance of the system.

[0005] In a first aspect, the present application provides a method for rapid message integration based on MNS, the method comprising:

[0006] When detecting the startup of a target application, obtaining configuration parameters related to MNS by scanning the configuration file of the target application;

[0007] Based on the configuration parameters related to MNS, establishing a connection instance with the MNS service;

[0008] Based on the MNS client connection factory, establishing a message system client instance;

[0009] Obtaining preset message annotation parameters;

[0010] A method for identifying a message processing method of the target application by using the preset message annotation parameters;

[0011] In response to the message processing method being identified by the message annotation parameters, create an MNS message listener instance for the message processing method;

[0012] Monitor the message queue corresponding to the message processing method through the MNS message listener instance;

[0013] When it is monitored that a message object arrives at the message queue, send the message object to the message processing method for processing.

[0014] In a second aspect, the present application provides a message fast integration device based on MNS, and the system includes:

[0015] A configuration parameter acquisition module, configured to obtain configuration parameters related to MNS by scanning a configuration file of the target application when it is detected that the target application is started;

[0016] A connection instance establishment module, configured to establish a connection instance with the MNS service based on the configuration parameters related to MNS;

[0017] A client instance establishment module, configured to establish a message system client instance based on the MNS client connection factory;

[0018] An annotation parameter acquisition module, configured to obtain preset message annotation parameters;

[0019] An identification module, configured to identify a message processing method of the target application by using the preset message annotation parameters;

[0020] A listener instance creation module, configured to create an MNS message listener instance for the message processing method in response to the message processing method being identified by the message annotation parameters;

[0021] A monitoring module, configured to monitor the message queue corresponding to the message processing method through the MNS message listener instance;

[0022] A message processing module, configured to send the message object to the message processing method for processing when it is monitored that a message object arrives at the message queue.

[0023] In a third aspect, an electronic device is provided, including a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory communicate with each other through the communication bus;

[0024] The memory is used for storing a computer program;

[0025] A processor, when executing a program stored in a memory, implements the steps of the MNS-based message fast integration method according to any one of the embodiments of the first aspect.

[0026] In a fourth aspect, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps of the MNS-based message fast integration method according to any one of the embodiments of the first aspect are implemented.

[0027] The above technical solutions provided by the embodiments of the present application have the following advantages compared with the prior art: (1) Significantly improve development efficiency. Since the dependency management and configuration processes are simplified, developers can quickly complete the integration of message services without in-depth understanding of the underlying technical details. And an intuitive and easy-to-use annotation method is provided, making the coding of message consumption and production logic more concise and efficient, greatly shortening the development cycle; (2) Enhance system stability and reliability. The system can maintain stable performance under different business loads and operating environments. Functions such as consumer watchdog and dynamic configuration enhance the system's ability to handle abnormal situations and adapt to business changes, effectively improving the reliability of the system; (3) Optimize system performance. Flexible concurrent consumption configuration and long polling timeout settings can optimize the efficiency of message acquisition and resource utilization according to actual business needs, improving the overall performance of the system. And the centralized and dynamic configuration management method reduces system restarts and service interruptions during configuration updates, ensuring the continuous and stable operation of the system. Description of the Drawings

[0028] The drawings here are incorporated into the specification and form a part of the specification, showing embodiments consistent with the present invention, and are used together with the specification to explain the principles of the present invention.

[0029] In order to more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the following will briefly introduce the drawings required for use in the description of the embodiments or the prior art. Obviously, for those of ordinary skill in the art, without creative efforts, other drawings can also be obtained based on these drawings.

[0030] Figure 1 It is a schematic flowchart of a method for fast integration of messages based on MNS provided by an embodiment of the present application;

[0031] Figure 2 It is a schematic flowchart of another method for fast integration of messages based on MNS provided by an embodiment of the present application;

[0032] Figure 3 It is a schematic structural diagram of an electronic device provided by an embodiment of the present application. Detailed Embodiments

[0033] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the following will clearly and completely describe the technical solutions in the embodiments of this application with reference to the accompanying drawings in the embodiments of this application. Obviously, the described embodiments are some, but not all, of the embodiments of this application. All other embodiments obtained by those of ordinary skill in the art based on the embodiments in this application without creative efforts shall fall within the scope of protection of this application.

[0034] Figure 1 It is a schematic flowchart of a method for fast integration of messages based on MNS provided by an embodiment of this application. Figure 1 The shown process can be executed by an electronic device, such as Figure 1 As shown, this process can include the following operations.

[0035] Step 101, when it is detected that the target application is started, obtain configuration parameters related to MNS by scanning the configuration file of the target application.

[0036] The target application refers to an application that needs to integrate a messaging system (such as MNS). For example, it can be a Web application, a microservice, or other types of systems.

[0037] The configuration file is a file used to store various parameters and configuration information of an application program. The configuration contains configurations related to MNS, such as queue names, concurrency numbers, timeouts, etc.

[0038] In some embodiments, the system can automatically scan the configuration file of the target application when the target application is started and read the configuration parameters related to MNS.

[0039] For example, the scanning of the configuration file and the reading of parameters can be completed through the @ConfigurationProperties annotation of Spring or a similar method.

[0040] Step 102, based on the configuration parameters related to MNS, establish a connection instance with the MNS service.

[0041] MNS (Message Notification Service) is a message service platform used to transmit messages in a distributed system. The connection instance is the actual communication channel with the MNS service. For example, through the MNS service, an e-commerce system can send order messages to a specified queue.

[0042] The connection instance is a connection established between the MNS client and the MNS service to ensure that the system can send or receive messages from the MNS service.

[0043] In some embodiments, the electronic device may create a connection instance according to configuration parameters to ensure that the target application can communicate with the MNS service. This process can be implemented through the SDK or custom code.

[0044] In some embodiments, establishing a connection instance with the MNS service based on the configuration parameters related to MNS may include: initializing the MNS client connection factory; and, based on the configuration parameters related to MNS, using the MNS client connection factory to establish the connection instance with the MNS service; the connection instance is used to manage the communication connection with the MNS service.

[0045] The MNS client connection factory provides corresponding methods to initialize and configure the connection instance. For example, when using the Java SDK, the connection factory can be the MnsClientFactory class, which is responsible for generating the connection instance according to configuration parameters (such as AccessKey, SecretKey, etc.).

[0046] When the application starts, first load the relevant configuration with the MNS service (such as queue name, authentication information, concurrency number, etc.) through the configuration file or code parameters, and then call the initialization method of the connection factory to configure and generate the connection instance. For example, an SDK can be used to create an instance of the connection factory.

[0047] Through the initialized connection factory, use the parameters loaded from the configuration (such as accessKey and secretKey) to establish a connection instance with the MNS service. The connection instance can be used for subsequent message communication with the MNS service.

[0048] The creation process of the connection instance is based on the MNS-related parameters in the configuration file, and these parameters can include identity authentication information and queue-related configurations. Through the connection instance, the application can perform stable message exchange with the MNS service to ensure reliable message delivery.

[0049] Step 103, establish a message system client instance based on the MNS client connection factory.

[0050] The MNS client connection factory is a tool for creating MNS client instances, which can provide the function of instantiating connections. For example, in a Spring environment, an @Bean configuration class can be used to create an instance of the connection factory.

[0051] The MNS client instance is the main object for interacting with the MNS service and is responsible for sending and receiving messages.

[0052] In some embodiments, an MNS client connection factory can be used to generate MNS client instances based on configured parameters (such as queue names, concurrency numbers, etc.).

[0053] In some embodiments, establishing a message system client instance based on the MNS client connection factory includes: determining the interaction operations with the MNS service; the interaction operations at least include message sending and receiving; and, encapsulating the interaction operations using the MNS client connection factory to obtain the message system client instance.

[0054] The interaction operation refers to the specific communication behavior between the application system and the MNS service. The interaction operations include message sending, receiving, and possible other management operations (such as message confirmation, deletion, etc.). For example, sending an order message to a specified queue through the MNS client, or receiving and processing messages from a certain queue.

[0055] After establishing a connection instance with the MNS service, the type of interaction operation can be determined. In this method, the interaction operations at least include message sending and receiving, which are the basic interactions between the system and the MNS service. The direction of message passing and the queue name can be determined by viewing the queue information in the configuration file.

[0056] Exemplarily, in an e-commerce system, the interaction operations can include message sending and message receiving. Message sending is used to send order information to a specified queue through the MNS service. Message receiving is used to receive processing results or status update messages from a specified queue.

[0057] In some embodiments, the electronic device can encapsulate the interaction operations (message sending and receiving) into a client instance through the connection factory. The client instance performs interactions with the MNS service through the unified interface of the connection factory, which can reduce the developer's attention to the underlying communication details.

[0058] Step 104, obtain the preset message annotation parameters.

[0059] The message annotation parameters are annotation parameters related to the message processing method. They can be attributes specified through custom annotations such as @MnsMqMessageListener, such as queue names, concurrent consumption quantities, etc.

[0060] In some embodiments, the preset message annotation parameters are obtained in the following manner: obtain the key attributes for flexibly controlling message consumption behavior; the key attributes include queue names, concurrent consumption quantities, long polling timeout durations, and consumption watchdog functions; and, based on the key attributes, define the message annotation parameters.

[0061] Key attributes refer to important configuration parameters used to flexibly control the behavior of consumers during message consumption. These parameters can affect the way messages are consumed, the number of concurrent processes during processing, the waiting time, etc., and thus affect the overall performance and reliability of the system.

[0062] The queue name is used to identify the source queue of the message, such as "orderQueue".

[0063] The number of concurrent consumptions refers to the number of messages that are allowed to be processed simultaneously, such as 5.

[0064] The long polling timeout duration refers to the maximum time that a consumer waits for a message when no message arrives, such as 30 seconds.

[0065] The consumption watchdog function is used to control whether to enable the health check or timeout detection function during consumption, such as enabling (true) or disabling (false).

[0066] In some embodiments, the key attributes can be obtained through a configuration file, a configuration center (such as Nacos), or a database, etc. For example, parameters such as the queue name, the number of concurrences, and the long polling timeout duration are dynamically read from the configuration center or the file.

[0067] Defining message annotation parameters means assigning these obtained key attributes to the message annotation parameters for dynamic control at runtime.

[0068] For example, define the queue name parameter: According to the read queue name parameter, pass it to the queue attribute of the annotation @MnsMqMessageListener. Use a dynamic value (such as ${mns.queue.name}) in the @MnsMqMessageListener annotation to specify the queue name.

[0069] Define the number of concurrent consumptions: Use the number of concurrent consumptions obtained from the configuration file to set the concurrentCount attribute in the annotation. Set the number of concurrent consumptions in the annotation to control the concurrent message processing ability of the system.

[0070] Define the long polling timeout duration: Obtain the long polling timeout duration from the configuration and apply it to the waitSeconds attribute of the annotation. Set the maximum time for the consumer to wait for a message to prevent long-term unresponsiveness.

[0071] Define the consumption watchdog function: Enable or disable the consumption watchdog function according to the configuration. Set the watchDog attribute to enable or disable exception handling and health monitoring during consumption.

[0072] Step 105, use the preset message annotation parameters to identify the message processing method of the target application.

[0073] The message processing method is a business logic method in the target application for consuming messages. For example, in the OrderSyncService class, the method onMessage(String message) may be annotated with the message annotation parameter @MnsMqMessageListener, indicating that this method is used to process order messages.

[0074] In some embodiments, all message processing methods that need to be marked can be identified according to the obtained annotation parameters, and these methods are marked as message consumers.

[0075] In some embodiments, the step of using the preset message annotation parameter to identify the message processing method of the target application may include the following operations.

[0076] S10, obtain all message processing methods of the target application.

[0077] A message processing method refers to an application method designed to process messages. These methods are marked with specific annotations (such as @MnsMqMessageListener) so as to trigger processing when messages arrive. For example, a method for processing order messages in the orderQueue queue

[0078] In some embodiments, all methods in the target application with the @MnsMqMessageListener annotation can be scanned, and these methods are collected as message processing methods.

[0079] S11, for each message processing method, perform method signature analysis, business logic speculation, and dynamic configuration reading on it.

[0080] Method signature analysis refers to analyzing information such as the input and output parameter types and method names of each message processing method, so as to speculate on the specific function and business scenario of the method. For example, the method signature is public void handleOrderMessage(Order order), where Order is the message type processed by this method. By analyzing the method signature, it can be known that it is used to process order messages.

[0081] Business logic speculation means speculating on what business logic the method processes according to the method signature and context information. For example, through the method signature handleOrderMessage(Order order), it can be speculated that this method processes business logic related to orders, such as order creation, modification, or status update.

[0082] Dynamic configuration reading refers to dynamically reading the parameter configurations related to this method according to the application's configuration file or configuration center, such as queue names, concurrency numbers, etc. For example, the configuration related to the queue name, such as "orderQueue", can be read from the configuration file, or the concurrentCount parameter can be read to determine the number of concurrent processes.

[0083] In some embodiments, for method signature analysis: First, the signature of each method can be obtained through reflection, and the input parameter types, output types, and method names of the method can be analyzed. For business logic speculation, its business logic can be analyzed based on the method signature and context, and the specific business it processes can be speculated, such as handleOrderMessage processing order creation, payment, etc. For dynamic configuration reading: Configuration parameters such as queue names and consumption quantities can be read from the application's configuration file (such as application.properties or Nacos, etc.).

[0084] S12. Based on the results of the key attributes, method signature analysis, business logic speculation, and dynamic configuration reading, determine whether to use the preset message annotation parameters to identify the message processing method.

[0085] Based on the results analyzed previously (method signature, business logic, and dynamic configuration), it can be determined whether this method should be identified using the preset message annotation parameters. For example, it can be checked whether certain specific business logics (such as processing orders) are contained in the method signature, and then it can be determined whether to use

[0086] the @MnsMqMessageListener annotation for identification.

[0087] According to the analysis and speculation results, appropriately apply annotations to each message processing method dynamically to ensure that the method can correctly process the messages in the specified queue.

[0088] In some embodiments, the determining whether to use the preset message annotation parameters to identify the message processing method based on the results of the key attributes, method signature analysis, business logic speculation, and dynamic configuration reading includes: inputting the results of the key attributes, method signature analysis, business logic speculation, and dynamic configuration reading into a preset machine learning model for processing to obtain a processing result; and based on the processing result, determining whether to use the preset message annotation parameters to identify the message processing method.

[0089] In some embodiments, the key attributes and the results of the method signature analysis, business logic speculation, and dynamic configuration reading can be input into a preset machine learning model for processing. For example, the prediction interface of the machine learning model can be called to pass the input into the model and obtain the processing result of the model.

[0090] The conclusion given by the machine learning model after analyzing the input data indicates whether the preset message annotation parameters need to be applied. For example, the processing result is True or False. True indicates that identification is required, and False indicates that identification is not required.

[0091] The preset machine learning model can be various models such as a deep learning neural network, and the specific model type is not limited in this embodiment.

[0092] In this embodiment, based on the key attributes, method signature analysis, business logic speculation, and the results of dynamic configuration reading, a preset machine learning model is used for processing to determine whether to apply the preset message annotation parameters, so as to flexibly and efficiently identify and configure the message processing method.

[0093] Step 106, in response to the message processing method being identified by the message annotation parameters, create an MNS message listener instance for the message processing method.

[0094] A message listener instance is an object responsible for listening for messages in a specific queue. When a message arrives, it can automatically call the corresponding message processing method.

[0095] For example, the message listener can be annotated with @MnsMqMessageListener and can be set according to information such as the queue name and the number of concurrency when instantiated.

[0096] In some embodiments, when the application starts, all methods annotated with message annotations can be scanned and a corresponding message listener instance can be created for each method.

[0097] Step 107, listen for the message queue corresponding to the message processing method through the MNS message listener instance.

[0098] A message queue is a container for storing messages. The producer sends the message to the queue, and the consumer reads the message from the queue and processes it.

[0099] For example, in an e-commerce system, orderQueue can be a queue for storing order messages.

[0100] In some embodiments, a message listener instance can be used to listen for the queue corresponding to the message processing method. When a message arrives at the queue, the listener can trigger the corresponding message processing method.

[0101] Step 108: When it is monitored that a message object arrives at the message queue, send the message object to the message processing method for processing.

[0102] A message object is a message stored in the queue, which contains the data content sent by the producer.

[0103] When the listener detects the arrival of a message object, it can pass the message object as a parameter to the message processing method to trigger the business logic processing.

[0104] Through the above steps, the system can dynamically load the configuration related to MNS when the application starts, create a message client and a listener, and automatically execute the message processing logic according to the annotation.

[0105] In this embodiment, it can significantly simplify the integration and development process of the message system, improve the reliability, performance and flexibility of message processing. At the same time, it provides a flexible configuration management and dynamic adjustment mechanism, enhances the scalability and adaptability of the system, and ensures stable operation under various business requirements and high load conditions.

[0106] Figure 2 It is a schematic flow diagram of another message fast integration method based on MNS provided by the embodiment of the present application. As Figure 2 shown, this process may include the following operations.

[0107] Step 201: Register the connection instance with the MNS service and the message system client instance as objects in the context of the target application.

[0108] The context refers to the environment or management container in the application. In this embodiment, it may refer to the dependency injection container, which is the Spring application context in the Spring framework. The Spring application context is a container responsible for managing and injecting all components in the application, such as connection instances and client instances.

[0109] In some embodiments, the connection instance of the MNS service and the message system client instance can be registered in the context of the target application. For example, it can be implemented through the way of dependency injection. Through the container mechanism of Spring, these instances will be automatically loaded when the application starts and can be called in different parts of the application. For example, in the Spring framework, the @Bean or @Component annotation can be used to define and register these instances, or manual injection can be used to complete the registration in the configuration class.

[0110] Step 202: Create a class in the target application that needs to be injected with the connection instance of the MNS service and the message client instance.

[0111] The class to be injected is the class in the target application that needs to use the MNS connection instance and the message client instance. For example, it can be a business logic class or a component class in the application that needs to interact with the message queue. For example, the "order processing class" in an e-commerce system needs to receive order status messages from MNS or send processing result messages to the MNS queue.

[0112] In the target application, create a class and define fields in the class to implement the MNS connection instance and the message client instance that can be used. These fields can be automatically filled through dependency injection. For example, in Spring, the @Autowired annotation can be used to mark the fields that need to be injected.

[0113] Step 203, inject the connection instance with the MNS service and the message client instance into the class through a preset dependency injection method; where the preset dependency injection method includes constructor injection and field injection.

[0114] Dependency injection is a technique for injecting the dependency relationships of objects into a class through an external method. The preset dependency injection method refers to an injection method that has been preset in advance, including constructor injection and field injection.

[0115] For example, in Spring, the commonly used dependency injection methods include constructor injection (passed in through the constructor) and field injection (annotated with the @Autowired annotation on the field).

[0116] Constructor injection is to pass the required dependencies into the class through the constructor of the class. In Spring, when using constructor injection, the dependencies can be passed to the object through the constructor when creating the object.

[0117] Field injection is to automatically inject dependencies by using the @Autowired annotation on the fields of the class. This method does not require an explicit definition of a constructor. For example, the MNS connection instance and the message client instance can be directly injected into the fields through the @Autowired annotation.

[0118] In the target application, by selecting an appropriate injection method, use constructor injection or field injection to inject the connection instance of the MNS service and the message client instance into the target class. These instances can be used by the methods in the class to perform operations such as sending and receiving messages.

[0119] The present application also provides a message rapid integration device based on MNS. According to the implemented functions, the message rapid integration device based on MNS may include multiple modules. The modules in the present application may also be referred to as units, which refer to a series of computer program segments that can be executed by the processor of an electronic device and can complete fixed functions, and are stored in the memory of the electronic device.

[0120] In this embodiment, the functions of each module / unit are as follows:

[0121] The configuration parameter acquisition module is used to obtain configuration parameters related to MNS by scanning the configuration file of the target application when it is detected that the target application starts;

[0122] The connection instance establishment module is used to establish a connection instance with the MNS service based on the configuration parameters related to MNS;

[0123] The client instance establishment module is used to establish a message system client instance based on the MNS client connection factory;

[0124] The annotation parameter acquisition module is used to obtain preset message annotation parameters;

[0125] The identification module is used to identify the message processing method of the target application by using the preset message annotation parameters;

[0126] The listener instance creation module is used to create an MNS message listener instance for the message processing method in response to the message processing method being identified by the message annotation parameters;

[0127] The listening module is used to listen to the message queue corresponding to the message processing method through the MNS message listener instance;

[0128] The message processing module is used to send the message object to the message processing method for processing when it is detected that a message object arrives at the message queue.

[0129] The specific implementation manner of the message rapid integration device based on MNS in the present application is substantially the same as that of the above-mentioned message rapid integration method based on MNS, and will not be elaborated herein.

[0130] As Figure 3 shown, the embodiment of the present application provides an electronic device, including a processor 111, a communication interface 112, a memory 113, and a communication bus 114. Among them, the processor 111, the communication interface 112, and the memory 113 complete mutual communication through the communication bus 114.

[0131] The memory 113 is used to store computer programs;

[0132] In an embodiment of the present application, when the processor 111 executes the program stored on the memory 113, it implements the method for fast integration of messages based on MNS provided by any of the foregoing method embodiments, including:

[0133] When detecting the startup of the target application, obtain configuration parameters related to MNS by scanning the configuration file of the target application;

[0134] Based on the configuration parameters related to MNS, establish a connection instance with the MNS service;

[0135] Based on the MNS client connection factory, establish a message system client instance;

[0136] Obtain preset message annotation parameters;

[0137] Use the preset message annotation parameters to identify the message processing method of the target application;

[0138] In response to the message processing method being identified by the message annotation parameters, create an MNS message listener instance for the message processing method;

[0139] Listen to the message queue corresponding to the message processing method through the MNS message listener instance;

[0140] When it is detected that a message object arrives at the message queue, send the message object to the message processing method for processing.

[0141] An embodiment of the present application also provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, it implements the steps of the method for fast integration of messages based on MNS provided by any of the foregoing method embodiments.

[0142] It should be noted that in this article, relational terms such as "first" and "second" are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the term "comprising", "including" or any other variant thereof is intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements not only includes those elements, but also includes other elements not expressly listed, or elements inherent to such process, method, article or device. Without further limitation, an element defined by the statement "including a..." does not exclude the existence of additional identical elements in the process, method, article or device including the element.

[0143] The above are only specific embodiments of the present invention, enabling those skilled in the art to understand or implement the present invention. Various modifications to these embodiments will be obvious to those skilled in the art, and the general principles defined herein can be implemented in other embodiments without departing from the spirit or scope of the present invention. Therefore, the present invention will not be limited to these embodiments shown herein, but rather to the broadest scope consistent with the principles and novel features claimed herein.

Claims

1. A method for rapid message integration based on MNS, characterized in that, The method includes: When detecting the startup of the target application, obtaining configuration parameters related to MNS by scanning the configuration file of the target application; Based on the configuration parameters related to MNS, establishing a connection instance with the MNS service; Based on the MNS client connection factory, establishing a message system client instance; Obtaining preset message annotation parameters; Using the preset message annotation parameters to identify the message processing method of the target application; In response to the message processing method being identified by the message annotation parameters, creating an MNS message listener instance for the message processing method; Listening to the message queue corresponding to the message processing method through the MNS message listener instance; When it is detected that a message object arrives at the message queue, sending the message object to the message processing method for processing.

2. The method according to claim 1, characterized in that, The establishing a connection instance with the MNS service based on the configuration parameters related to MNS includes: Initializing the MNS client connection factory; Based on the configuration parameters related to MNS, using the MNS client connection factory to establish the connection instance with the MNS service; the connection instance is used to manage the communication connection with the MNS service.

3. The method according to claim 1, characterized in that, The establishing a message system client instance based on the MNS client connection factory includes: Determining the interaction operations with the MNS service; the interaction operations at least include message sending and receiving; Using the MNS client connection factory to encapsulate the interaction operations to obtain the message system client instance.

4. The method according to claim 1, wherein The method further includes: Registering the connection instance with the MNS service and the message system client instance as objects in the context of the target application; Creating a class in the target application that needs to be injected with the connection instance with the MNS service and the message client instance; Through a preset dependency injection method, injecting the connection instance with the MNS service and the message client instance into the class; wherein, the preset dependency injection method includes constructor injection and field injection.

5. The method according to claim 1, wherein The preset message annotation parameters are obtained through the following method: Obtaining key attributes for flexibly controlling message consumption behavior; the key attributes include queue name, concurrent consumption quantity, long polling timeout duration, and consumption watchdog function; Based on the key attributes, defining to obtain the message annotation parameters.

6. The method according to claim 5, wherein The using the preset message annotation parameters to identify the message processing method of the target application includes: Obtaining all message processing methods of the target application; For each message processing method, performing method signature analysis, business logic speculation, and dynamic configuration reading on it; Based on the key attributes and the results of the method signature analysis, business logic speculation, and dynamic configuration reading, determining whether to use the preset message annotation parameters to identify the message processing method.

7. The method according to claim 6, wherein The determining whether to use the preset message annotation parameters to identify the message processing method based on the key attributes and the results of the method signature analysis, business logic speculation, and dynamic configuration reading includes: Input the results of the analysis of the key attributes, the speculation of the method signature, and the reading of the dynamic configuration into a preset machine learning model for processing to obtain a processing result; Based on the processing result, determine whether to use the preset message annotation parameters to identify the message processing method.

8. A message fast integration device based on MNS, characterized in that The system includes: A configuration parameter acquisition module, configured to, when detecting that a target application is started, acquire configuration parameters related to MNS by scanning a configuration file of the target application; A connection instance establishment module, configured to establish a connection instance with an MNS service based on the configuration parameters related to MNS; A client instance establishment module, configured to establish a message system client instance based on the MNS client connection factory; An annotation parameter acquisition module, configured to acquire preset message annotation parameters; An identification module, configured to use the preset message annotation parameters to identify a message processing method of the target application; A listener instance creation module, configured to, in response to the message processing method being identified by the message annotation parameters, create an MNS message listener instance for the message processing method; A listening module, configured to listen to a message queue corresponding to the message processing method through the MNS message listener instance; A message processing module, configured to, when it is detected that a message object arrives at the message queue, send the message object to the message processing method for processing.

9. An electronic device, characterized in that, Including a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory complete communication with each other through the communication bus; The memory is used for storing a computer program; The processor is configured to, when executing the program stored on the memory, implement the steps of the method for fast message integration based on MNS according to any one of claims 1-7.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the steps of the method for fast message integration based on MNS according to any one of claims 1-7.