Message production consumption method and system and message production consumption equipment
By uniformly defining the message interface and generating proxy classes, the problems of technical complexity, high learning cost, poor business correlation and increased maintenance difficulty in the existing message middleware usage scheme are solved, and higher business correlation and code maintainability are achieved.
Patent Information
- Application Number
- CN202510219308.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-26
- Publication Date
- 2025-06-10
AI Technical Summary
The existing messaging middleware usage solutions have problems such as technical complexity, high learning costs, poor business relevance and increased maintenance difficulties. Especially the lack of direct business connections between independent production and consumer ends, which makes it difficult to track and manage the entire business process when the system complexity increases.
By uniformly defining the message interface, a message sending proxy class corresponding to the message interface is generated and injected into the service class created by the Spring container to generate a message and call the message sending proxy class to send the message to the message middleware. At the same time, based on dynamic proxy technology, a proxy class of message middleware is generated, messages in message middleware are received, and messages are consumed based on message consumption business logic.
It improves business relevance, reduces the maintenance cost of the code layer, decouples the message production and consumer side and the specific message middleware implementation, blocks the docking process of the message middleware, improves the readability and reusability of the code, and reduces the cost of learning entry.
Smart Images

Figure CN120123121A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular, to a message production and consumption method, system, and message production and consumption device. Background Art
[0002] Message middleware refers to the basic software that completes the sending and receiving of messages in a distributed system. In Internet scenarios, message middleware is often used for operations such as message routing, subscription and publication, and asynchronous processing to relieve the pressure on the system.
[0003] In the existing usage scenarios of message middleware, it is usually necessary to define an independent production end for sending messages and an independent consumption end for message consumption.
[0004] However, there are technical complexity problems in defining independent production and consumption ends to implement message sending and consumption. The use of message queues is not simple. There are many message middleware available on the market currently (such as RabbitMQ, ActiveMQ, Kafka, RocketMQ, ZeroMQ, MetaMQ, etc.), and the access costs and usage methods of each message middleware are different. If one is not familiar with message queues, it is difficult to build robust, stable, and highly maintainable message publishing and consumption code, and there is a problem of high learning cost. For developers newly joining the team, it may take a certain amount of time to learn and master the use and configuration of specific message middleware, and there is a problem of poor business relevance. The message mechanism reduces the coupling degree between the sender and the receiver. Both parties only need to care about the format and content of the message without understanding the specific implementation details of the other party. However, this high degree of decoupling also brings a lack of business relevance. Since the sender and the consumer are developed independently, there is a lack of direct business connection between them, resulting in difficulties in tracking and managing the entire business process when the system complexity increases, and there is a problem of increased maintenance difficulty. Since the sender and the consumer are developed independently, it is very difficult to quickly locate the root cause of the problem when the system has problems. For example, when the consumer cannot consume messages correctly, it may be caused by incorrect message formats, incorrect message middleware configurations, or defects in the consumer code. Due to the lack of direct business connection between the sender and the consumer, it becomes more difficult to troubleshoot problems. Summary of the Invention
[0005] In view of this, it is necessary to provide a message production and consumption method, system, and message production and consumption device to solve the technical problems of technical complexity, high learning cost, poor business relevance, and increased maintenance difficulty in defining independent production and consumption ends to implement message sending and consumption.
[0006] To solve the above problems, in a first aspect, the present invention provides a message production and consumption method, which is applied to a message production end and includes: Uniformly define a message interface, and generate a message sending proxy class corresponding to the message interface according to the uniformly defined message interface; Inject the message sending proxy class into a service class corresponding to the message production end created by the Spring container to generate a message, and call the message sending proxy class to send the message to a message middleware, and the message in the message middleware can be received and consumed by a message consumption end.
[0007] In a possible implementation manner, before uniformly defining the message interface, it includes: Determine the consumption method, consumption topic, and message content entity of the message according to the agreement between the message production end and the message consumption end.
[0008] In a possible implementation manner, the message interface includes multiple interface methods; the uniformly defining the message interface includes: Based on the agreement between the message production end and the message consumption end, uniformly define the message interface, and add a first annotation and a second annotation to the signature of the message interface and the interface method respectively to specify the consumption method, consumption topic, and message content entity of the message. Among them, the parameter of the interface method is the message content entity, the first annotation is AsyncClient, the second annotation is AsyncNotify, and the attributes of the second annotation at least include message description, message topic, consumption group, message label, consumption method, and delayed consumption level.
[0009] In a possible implementation manner, the generating a message sending proxy class corresponding to the message interface according to the uniformly defined message interface includes: Obtain the interface method modified by the second annotation according to the uniformly defined message interface; Generate a message sending proxy class corresponding to the interface method based on dynamic proxy technology. Among them, the parameter of the interface method is converted through the message sending proxy class to obtain a message sending entity, and the attributes of the second annotation are interpreted to determine the message middleware.
[0010] In a possible implementation manner, the injecting the message sending proxy class into a service class corresponding to the message production end created by the Spring container to generate a message, and calling the message sending proxy class to send the message to the message middleware includes: After declaring the message sending proxy class, inject the message sending proxy class into Spring; Create a service class corresponding to the message producer through the Spring container; Inject the message sending proxy class into the service class through the dependency injection technology of Spring to generate message sending business logic and messages; Execute the message sending business logic, and call the message sending proxy class to send the messages corresponding to the consumption topic and consumption method specified in the message interface to the message middleware.
[0011] In a possible implementation manner, the injecting the message sending proxy class into the service class through the dependency injection technology of Spring includes: Inject the message sending proxy class into the service class through the IoC method of Spring.
[0012] In a second aspect, the present invention further provides a message production and consumption method, which is applied to a message consumer end and includes: Implement the message interface defined by the message producer end to generate a message consumption class, and determine message consumption business logic based on the message consumption class; Based on the dynamic proxy technology, generate a proxy class of the message middleware according to the implemented message interface, receive the messages in the message middleware based on the proxy class of the message middleware, and consume the messages based on the message consumption business logic.
[0013] In a possible implementation manner, the receiving the messages in the message middleware based on the proxy class of the message middleware includes: Based on the proxy class of the message middleware, receive the messages corresponding to the consumption method and consumption topic in the message middleware according to the consumption method and consumption topic of the messages specified in the message interface.
[0014] In a third aspect, the present invention further provides a message production and consumption system, including a message producer end and a message consumer end; The message producer end is used to uniformly define a message interface, and generate a message sending proxy class corresponding to the message interface according to the uniformly defined message interface; The message producer end is further used to inject the message sending proxy class into a service class corresponding to the message producer end created through the Spring container to generate messages, and call the message sending proxy class to send the messages to the message middleware; The message consumer end is used to implement the message interface uniformly defined by the message producer end to generate a message consumption class, and determine message consumption business logic based on the message consumption class; The message consumer is further configured to generate a proxy class of the message middleware based on the implemented message interface according to the dynamic proxy technology, receive messages in the message middleware based on the proxy class of the message middleware, and consume the messages based on the message consumption service logic.
[0015] Fourthly, the present invention further provides a message production and consumption device, including: a processor and a memory; A computer-readable program executable by the processor is stored on the memory; When the processor executes the computer-readable program, the steps in the message production and consumption method described above are implemented.
[0016] The beneficial effects of the present invention are as follows: The message interface is uniformly defined. Through the unified interface definition, the service logics of the message producer and the message consumer are associated, improving the service relevance and reducing the maintenance cost at the code layer. A message sending proxy class corresponding to the message interface is generated according to the uniformly defined message interface, and the message sending proxy class is injected into the service class corresponding to the message producer created by the Spring container, so that the message consumer receives messages in the message middleware and consumes the messages. By using the dependency injection of the Spring framework, the proxy class is injected into the service class, decoupling the logics of the message producer and the message consumer from the specific message middleware, shielding the docking process of the message middleware, and handing over the details of message transmission to the Spring framework and the message middleware for processing, improving the readability of the code and reducing the learning and getting-started cost. Description of the Drawings
[0017] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following will briefly introduce the drawings required for the description of the embodiments. Obviously, the following drawings are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative efforts.
[0018] Figure 1 It is a flowchart of an embodiment of the message producer of the message production and consumption method provided by the present invention; Figure 2 It is a flowchart of an embodiment of the message consumer of the message production and consumption method provided by the present invention; Figure 3 It is a schematic structural diagram of an embodiment of the message production and consumption system provided by the present invention; Figure 4 It is a schematic structural diagram of an embodiment of the message production and consumption device provided by the present invention. Detailed Embodiments
[0019] Next, the technical solutions in the embodiments of the present invention will be clearly and completely described in conjunction with the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only a part of the embodiments of the present invention, rather than all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative work fall within the protection scope of the present invention.
[0020] In the description of the embodiments of the present invention, unless otherwise specified, the meaning of "a plurality" is two or more. "And / or" describes the association relationship of associated objects, indicating that there can be three relationships. For example, A and / or B can represent: A exists alone, A and B exist simultaneously, and B exists alone.
[0021] The descriptions such as "first" and "second" involved in the embodiments of the present invention are only for descriptive purposes, and cannot be understood as indicating or implying their relative importance or implicitly indicating the quantity of the indicated technical features. Therefore, the technical features defined with "first" and "second" may explicitly or implicitly include at least one such feature.
[0022] Referring to "embodiments" in this article means that the specific features, structures, or characteristics described in connection with the embodiments may be included in at least one embodiment of the present invention. The occurrence of this phrase in various positions in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment mutually exclusive with other embodiments. Those skilled in the art explicitly and implicitly understand that the embodiments described herein can be combined with other embodiments.
[0023] Before presenting the embodiments, the following terms are explained first.
[0024] Spring is an open-source enterprise-level Java application development framework. It provides comprehensive infrastructure support for developers, simplifies the development process of Java enterprise applications, and the design goal of the Spring framework is to solve the complexity problems in enterprise application development.
[0025] IoC (Inversion of Control): Spring promotes loose coupling through a technique called Inversion of Control. When IoC is applied, other objects that an object depends on are passed in passively, rather than the object creating or looking up the dependent objects by itself.
[0026] Annotations: Widely used in the definition and configuration of message interfaces, helping developers handle the production and consumption of messages more concisely and flexibly. The use of annotations is usually closely combined with the dependency injection mechanism of the Spring framework, making the definition and implementation of message interfaces more flexible and modular.
[0027] The present invention discloses a message production and consumption method, system, and message production and consumption device, which can be used in a computer. The method, device, or computer-readable storage medium involved in the present invention can either be integrated with the above-mentioned device or be relatively independent.
[0028] A specific embodiment of the present invention discloses a message production and consumption method, which can be executed by a computer, specifically by one or more processors of the computer. As Figure 1 shown, the message production and consumption method is applied to the message production side and includes: S101. Uniformly define the message interface, and generate a message sending proxy class corresponding to the message interface according to the defined message interface.
[0029] It should be noted that the message interface is applied to the message sending and / or consumption scenario, that is, the message production side and the message consumption side send and consume messages based on the message interface. By uniformly defining the message interface, through the unified interface definition, the business logics of the message production side and the message consumption side are associated, improving the business relevance. Through the dynamic proxy technology, a proxy object can be created to encapsulate the interaction logic with the message middleware, thereby hiding the details of the message middleware, enabling the message production side and the message consumption side not to directly depend on a specific message middleware to implement message sending and consumption, and realizing the decoupling of the message production side and the message consumption side from the message middleware, which can greatly improve the maintainability and reusability of the code.
[0030] S102. Inject the message sending proxy class into the service class corresponding to the message production side created by the Spring container to generate a message, and call the message sending proxy class to send the message to the message middleware. The message in the message middleware can be received and consumed by the message consumption side.
[0031] It should be noted that Spring uses the inversion of control (IOC) technology to achieve loose coupling. The message sending proxy class is injected into the object, greatly simplifying the development process and enabling developers to focus more on the implementation of the business logic.
[0032] In some embodiments of the present invention, in step S101, before the message producer uniformly defines the message interface, the message producer and the message consumer make an agreement. According to the agreement between the message producer and the message consumer, the consumption method, consumption topic, and message content entity of the message are determined; based on the agreement between the message producer and the message consumer, the message producer uniformly defines the message interface. The message interface includes multiple interface methods, and the first annotation and the second annotation are respectively added to the message interface and the signature of the interface method to specify the consumption method, consumption topic, and message content entity. Among them, the parameter of the interface method is the message content entity, the first annotation is AsyncClient, and the second annotation is AsyncNotify. The attributes of the second annotation at least include message description, message topic, consumption group, message tag, consumption method, and delayed consumption level; The message interface definition is modified with the first annotation AsyncClient to indicate that the message interface is applied to the message sending / consuming scenario; there is no member attribute definition inside the annotation. Multiple methods can be defined in one message interface, and each interface method represents a message delivery / consumption method. The definition of the interface method satisfies the following agreement: the parameter of the interface method represents the message body used for sending and consuming, and the message body is the message content entity; the interface method returns a fixed boolean value. For the message producer, when returning true, it means the message delivery is successful, and when returning false, it means the message delivery fails; for the message consumer, when returning true, it means the message is successfully consumed, and when returning false, it means the message consumption fails; on the signature of the method, the second annotation @AsyncNotify is added. The second annotation is a custom annotation, and the attributes of the second annotation include: value: of type String, representing the message description, which is a required item; topic, the consumption topic, of type String, which is an optional item, indicating in the message subscription mode which specific consumption topic the message is sent to and from which consumption topic the consumer consumes data; consumerGroup, the consumption group, of type String, which is an optional item; tag, the message tag, of type String, which is an optional item; consumeMode, the consumption method, of type String, defaulting to the mode where the message middleware pushes messages to the consumer, and the optional mode is that the message consumer actively pulls messages from the message middleware; delayLevel, the delayed consumption level, of type String, defaulting to empty indicating real-time consumption. If the value is non-empty, it means this message belongs to the delayed consumption queue, and its corresponding value range and delayed consumption duration are: 1s, 5s, 10s, 30s, 1m, 2m, 3m, 4m, 5m, 6m, 7m, 8m, 9m, 10m, 20m, 30m, 1h, 2h.
[0033] Generate a message sending proxy class corresponding to the message interface according to the uniformly defined message interface. According to the uniformly defined message interface, obtain the interface methods decorated with the second annotation, that is, the message content entity, consumption method, and consumption topic of the message can be obtained. Generate a message sending proxy class corresponding to the interface method based on the dynamic proxy technology. Among them, the parameters of the interface method are converted by the message sending proxy class to obtain the message sending entity, and the attributes of the second annotation are interpreted to determine the message middleware; scan the interface methods declared with the second annotation @AsyncNotify on all classes, and generate a message sending proxy class for the interface declared with the second annotation based on the dynamic proxy technology. The message sending proxy class is a dynamic proxy class. The parameters of the interface method are converted into a unified message sending entity by the message sending proxy class, and the attributes of the second annotation on the interface method are read to determine the message middleware for message delivery, and further determine the target queue in the message middleware, that is, determine the message middleware for delivering messages according to the consumption method and consumption topic specified by the second annotation.
[0034] In some embodiments of the present invention, in step S102, the message sending proxy class is injected into the service class corresponding to the message production end created by the Spring container to generate a message. After declaring the message sending proxy class, the message sending proxy class is injected into Spring, that is, injected into the context of Spring. The service class corresponding to the message production end is created through the Spring container, and the message sending proxy class is injected into the service class through the dependency injection technology of Spring to generate the message sending business logic and the message, that is, the message sending proxy class is injected into the service class through the IoC method of Spring to generate the message sending business logic and the message. The service class contains the business logic of generating a message and calling the message sending proxy class to send the message; execute the message sending business logic, and call the message sending proxy class to send the message corresponding to the consumption topic and consumption method specified in the message interface to the message middleware. The message production end sends the message to the message middleware by calling the message sending proxy class in the service class, and the message in the message middleware can be received and consumed by the message consumer end.
[0035] In the production instance of delivering messages, the production instance is the service class. Projects using the Spring framework can directly achieve dependency injection of the message interface through @Autowired. For non-Spring framework Java projects, they can be injected through the tool AsyncNotifyProvider.getProixy(interface class); the message production end injects the defined message interface through the IoC method of Spring where messages need to be sent, and then calls the method of the interface to implement message sending.
[0036] A specific embodiment of the present invention discloses a message production and consumption method. As Figure 2 shown, the message production and consumption method is applied to the message consumption end and includes: S201. Implement the message interface uniformly defined by the message production end to generate a message consumption class, and determine the message consumption service logic based on the message consumption class; S202. Based on the dynamic proxy technology, generate a proxy class of the message middleware according to the implemented message interface, receive the messages in the message middleware based on the proxy class of the message middleware, and consume the messages based on the message consumption service logic.
[0037] In some embodiments of the present invention, in step S201, the message interface uniformly defined by the message production end is implemented to generate a message consumption class, and the message consumption service logic is determined based on the message consumption class. According to the actual business requirements, the message consumption end implements the message interface uniformly defined by the message production end, that is, implements all the interface methods in the message interface. The implemented interface methods are the specific business logics of message consumption, that is, the message consumption service logic. When the message consumption service logic is executed successfully, return true; when the message consumption service logic fails, return false.
[0038] In some embodiments of the present invention, in step S202, based on the dynamic proxy technology, a proxy class of the message middleware is generated according to the implemented message interface. Based on the proxy class of the message middleware, receive the messages in the message middleware. Based on the proxy class of the message middleware, receive the messages corresponding to the consumption method and consumption theme in the message middleware according to the consumption method and consumption theme specified in the message interface, and consume the messages based on the message consumption service logic. Scan the implementations of all message interfaces, and based on the dynamic proxy technology, generate a proxy class of the message middleware. The proxy class is responsible for interacting with the message middleware and is used to actively pull messages or receive the message push of the message middleware according to the consumption method defined on the interface. When the message consumption end actively pulls messages according to the consumption method, periodically query messages from the message middleware. After querying the corresponding messages, the message middleware pushes the messages to the message consumption end. The message consumption end parses the message content entity of the message by executing the message consumption service logic to complete the consumption of the message, and executes the consumption result confirmation with the message middleware through the proxy class of the message middleware. When the message consumption is successful, delete this message; when the message is not consumed, consume this message again.
[0039] In summary, the message production and consumption method provided by the present invention uniformly defines a message interface, generates a message sending proxy class corresponding to the message interface according to the uniformly defined message interface; injects the message sending proxy class into the service class corresponding to the message production end created by the Spring container to generate a message, and calls the message sending proxy class to send the message to the message middleware. The message in the message middleware can be received and consumed by the message consumption end, improving the business relevance and greatly reducing the learning and entry costs.
[0040] To better implement the message production and consumption method in the embodiments of the present invention, correspondingly, based on the message production and consumption method, as Figure 3 shown, the embodiments of the present invention further provide a message production and consumption system. The message production and consumption system 300 includes a message production end 301 and a message consumption end 302; The message production end 301 is used to uniformly define a message interface and generate a message sending proxy class corresponding to the message interface according to the uniformly defined message interface; The message production end 301 is further used to inject the message sending proxy class into the service class corresponding to the message production end created by the Spring container to generate a message, and call the message sending proxy class to send the message to the message middleware; The message consumption end 302 is used to implement the message interface uniformly defined by the message production end to generate a message consumption class, and determine the message consumption business logic based on the message consumption class; The message consumption end 302 is further used to generate a proxy class of the message middleware based on the implemented message interface by means of dynamic proxy technology, receive the message in the message middleware based on the proxy class of the message middleware, and consume the message based on the message consumption business logic.
[0041] As Figure 4 shown, the present invention also correspondingly provides a message production and consumption device 400. The message production and consumption device 400 can be a computing device such as a mobile terminal, a desktop computer, a notebook, a palm computer, and a server. The message production and consumption device 400 includes a processor 401, a memory 402, and a display 403. Figure 4 Only some components of the message production and consumption device 400 are shown, but it should be understood that it is not required to implement all the shown components, and more or fewer components can be alternatively implemented.
[0042] The memory 402 may be an internal storage unit of the message production and consumption device 400 in some embodiments, such as the hard disk or memory of the message production and consumption device 400. The memory 402 may also be an external storage device of the message production and consumption device 400 in other embodiments, such as a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) card, a Flash Card, etc. equipped on the message production and consumption device 400. Further, the memory 402 may also include both the internal storage unit of the message production and consumption device 400 and the external storage device. The memory 402 is used to store application software installed on the message production and consumption device 400 and various types of data, such as program codes installed on the message production and consumption device 400. The memory 402 may also be used to temporarily store data that has been output or will be output. In one embodiment, a message production and consumption program is stored on the memory 402, and the message production and consumption program can be executed by the processor 401, so as to implement the message production and consumption method of each embodiment of the present invention.
[0043] The processor 401 may be a central processing unit (CPU), a microprocessor or other data processing chips in some embodiments, and is used to run the program codes stored in the memory 402 or process data, such as the message production and consumption method, etc.
[0044] The display 403 may be an LED display, a liquid crystal display, a touch liquid crystal display, and an OLED (Organic Light-Emitting Diode) toucher, etc. in some embodiments. The display 403 is used to display the identification information of the message production and consumption program and to display a visual user interface. The components 401-403 of the message production and consumption device 400 communicate with each other through the system bus.
[0045] In some embodiments, when the processor 401 executes the message production and consumption program in the memory 402, each step in the message production and consumption method described in the above embodiments is implemented. Since the message production and consumption method has been described in detail above, it will not be elaborated here.
[0046] Furthermore, the embodiments of the present invention do not specifically limit the type of the message production and consumption device 400 mentioned. The message production and consumption device 400 may be a portable message production and consumption device such as a mobile phone, a tablet computer, a personal digital assistant (PDA), a wearable device, a laptop, etc. Exemplary embodiments of the portable message production and consumption device include, but are not limited to, portable message production and consumption devices equipped with IOS, android, microsoft or other operating systems. The above-mentioned portable message production and consumption device may also be other portable message production and consumption devices, such as a laptop with a touch-sensitive surface (such as a touch panel). It should also be understood that in some other embodiments of the present invention, the message production and consumption device 400 may not be a portable message production and consumption device, but a desktop computer with a touch-sensitive surface (such as a touch panel).
[0047] Correspondingly, the present invention also provides a computer-readable storage medium for storing computer-readable programs or instructions. When the programs or instructions are executed by a processor, the steps or functions in the message production and consumption methods provided by the above method embodiments can be implemented.
[0048] Those skilled in the art can understand that all or part of the processes of implementing the methods in the above embodiments can be completed by instructing relevant hardware through a computer program, and the program can be stored in a computer-readable storage medium. Among them, the computer-readable storage medium is a magnetic disk, an optical disk, a read-only memory or a random access memory, etc.
[0049] The above is only the preferred specific implementation manner of the present invention, but the protection scope of the present invention is not limited thereto. Any changes or substitutions that can be easily thought of by those skilled in the art within the technical scope disclosed by the present invention should be covered by the protection scope of the present invention.
Claims
1. A message production and consumption method, applied to a message production end, characterized in that: include: A message interface is uniformly defined, and a message sending agent class corresponding to the message interface is generated according to the uniformly defined message interface; The message sending proxy class is injected into the service class corresponding to the message production end created by the Spring container to generate a message, and the message sending proxy class is called to send the message to the message middleware. The message in the message middleware can be received and consumed by the message consumer end.
2. The message production and consumption method according to claim 1, characterized in that: The unified definition of the message interface includes: According to the agreement between the message producer and consumer, determine the message consumption method, consumption topic, and message content entity.
3. The message production and consumption method according to claim 2, characterized in that: The message interface includes multiple interface methods; the message interface is uniformly defined, including: Based on the agreement between the message production end and the message consumption end, the message interface is uniformly defined, and the first annotation and the second annotation are respectively added to the signature of the message interface and the interface method to specify the message consumption mode, consumption subject and message content entity, wherein the parameter of the interface method is the message content entity, the first annotation is AsyncClient, the second annotation is AsyncNotify, and the attributes of the second annotation include at least message description, message subject, consumption group, message tag, consumption mode and delayed consumption level.
4. The message production and consumption method according to claim 3 is characterized in that: The generating a message sending agent class corresponding to the message interface according to the uniformly defined message interface comprises: According to the uniformly defined message interface, an interface method modified by a second annotation is obtained; A message sending proxy class corresponding to the interface method is generated based on dynamic proxy technology, wherein the parameters of the interface method are converted by the message sending proxy class to obtain the message sending entity, and the attributes of the second annotation are interpreted to determine the message middleware.
5. The message production and consumption method according to claim 4 is characterized in that: The step of injecting the message sending proxy class into a service class corresponding to the message production end created by the Spring container to generate a message, and calling the message sending proxy class to send the message to the message middleware includes: After declaring the message sending proxy class, inject the message sending proxy class into Spring; Create a service class corresponding to the message production end through the Spring container; Inject the message sending proxy class into the service class through Spring's dependency injection technology to generate message sending business logic and messages; Execute the message sending business logic, call the message sending agent class to send the message corresponding to the consumption topic and consumption mode specified in the message interface to the message middleware.
6. The message production and consumption method according to claim 4, characterized in that: The method of injecting the message sending proxy class into the service class by using Spring's dependency injection technology includes: The message sending proxy class is injected into the service class through Spring's IoC method.
7. A message production and consumption method, characterized in that: Applied to message consumption end, including: Implement the message interface uniformly defined by the message production end to generate a message consumption class, and determine the message consumption business logic based on the message consumption class; Based on the dynamic proxy technology, a proxy class of the message middleware is generated according to the implemented message interface, the message in the message middleware is received based on the proxy class of the message middleware, and the message is consumed based on the message consumption business logic.
8. The message production and consumption method according to claim 7, characterized in that: The proxy class based on the message middleware receives the message in the message middleware, including: Based on the proxy class of the message middleware, according to the consumption mode and consumption topic of the message specified in the message interface, the message corresponding to the consumption mode and consumption topic in the message middleware is received.
9. A message production and consumption system, characterized in that: Including message production and message consumption; The message production end is used to uniformly define the message interface, and generate a message sending agent class corresponding to the message interface according to the uniformly defined message interface; The message production end is also used to inject the message sending proxy class into the service class corresponding to the message production end created by the Spring container to generate a message, and call the message sending proxy class to send the message to the message middleware; The message consumer is used to implement the message interface uniformly defined by the message producer to generate a message consumer class, and determine the message consumption business logic based on the message consumer class; The message consumer end is also used to generate a proxy class of the message middleware based on the implemented message interface based on dynamic proxy technology, receive messages in the message middleware based on the proxy class of the message middleware, and consume the messages based on the message consumption business logic.
10. A message production and consumption device, characterized in that: including memory and processor; The memory stores a computer-readable program executable by the processor; When the processor executes the computer-readable program, the processor implements the steps in the message production and consumption method as described in any one of claims 1-8.