Unitized message processing method, message gateway and message processing system
By obtaining the message and determining the target data and type, determining the target service unit and service code according to the configuration file, and sending the request message to the target service unit for processing, the problem of low message content processing efficiency in the existing technology is solved, and efficient Message unit processing and concurrent processing capabilities.
Patent Information
- Application Number
- CN202111645362.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-29
- Publication Date
- 2024-10-01
- Estimated Expiration
- 2041-12-29
AI Technical Summary
In the existing technology, it is difficult to unitize message content, resulting in insufficient message loss prevention capabilities and low concurrent processing capabilities.
By obtaining the message and determining the target data and message type, determine the target service unit and service code according to the configuration file, send the request message to the target service unit for processing, and perform message receipt and status update when necessary to ensure the reliability and reliability of the message. Execution rate.
It achieves efficient unit processing of message content, improves the system's concurrent processing capabilities and message execution rate, and solves the problems of message loss prevention and low processing efficiency.
Smart Images

Figure CN114338381B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of message processing, and in particular, to a unitized message processing method, a message gateway, a computer-readable storage medium, a processor, and a message processing system. Background Art
[0002] In the unitized architecture platform of microservices, due to the business needs of asynchronous processing, asynchronous processing and decoupling of services will be implemented in the form of messages with the help of various message middleware. However, in the specific implementation process, data will be obtained through EDB (Enterprise Data Bus, EDB for short). After receiving the data, EDB usually requires a message gateway to be responsible for receiving messages from the message queue in the EDB.
[0003] Since EDB was originally designed to be used as a data bus, the capabilities of the message middleware were not deeply explored, the message loss prevention capability was lacking, and unit processing of message content has not yet been achieved.
[0004] Therefore, there is an urgent need for a method that can unitize message content.
[0005] The above information disclosed in the background technology section is only used to enhance the understanding of the background technology of the technology described in this article. Therefore, the background technology may contain certain information that does not form the prior art known in this country for those skilled in the art. Summary of the invention
[0006] The main purpose of the present application is to provide a unitized message processing method, a message gateway, a computer-readable storage medium, a processor and a message processing system to solve the problem in the prior art that it is difficult to process message contents in a unitized manner.
[0007] According to one aspect of an embodiment of the present invention, a method for unitized processing of messages is provided, comprising: obtaining a message, and determining target data in the message and the type of the message, the target data being data transmitted by the message; determining a target service unit and a target service code according to a configuration file and the type of the message, the configuration file being a pre-configured file, the target service code being a unique identifier of a target service, and the target service being one of multiple services in the target service unit; and sending a request message carrying the target service code and the target data to the target service unit, so that the target service unit determines the corresponding target service according to the target service code, and uses the target service to process the target data.
[0008] Optionally, determining the target service unit and the target service code according to the configuration file and the type of the message includes: determining the configuration file according to the type of the message; and determining the target service unit and the target service code corresponding to the message according to the configuration file.
[0009] Optionally, obtaining the message includes: obtaining the message when the thread pool is not busy; and pausing obtaining the message and controlling the thread pool to sleep when the thread pool is busy or the message in the enterprise data bus is empty.
[0010] Optionally, determining the target data in the message and the type of the message includes: parsing the message to obtain the target data, the type of the message and the unique identifier of the message; determining whether the message has been stored in a database based on the unique identifier of the message; if the message has been stored in the database, not storing the message in the database and sending a first receipt message to an enterprise data bus; if the message has not been stored in the database, storing the message in the database and sending a second receipt message to the enterprise data bus.
[0011] Optionally, after the target service is used to process the target data, the method further includes: receiving a response message, the response message being used to characterize the processing status of the target service on the target data, the processing status including one of the following: successful execution, unsuccessful execution; and updating the status of the message stored in the database according to the response message.
[0012] Optionally, the method also includes: polling the status of all the messages in the database according to a predetermined time interval, and determining the number of unsuccessful executions of the messages that were not successfully executed; when the number of unsuccessful executions is less than or equal to a predetermined value, encapsulating the message into the request message again, and sending the re-encapsulated request message to the target service unit; when the number of unsuccessful executions is greater than the predetermined value, updating the status of the message to execution failure.
[0013] Optionally, before obtaining a message and determining the target data in the message and the type of the message, the method further includes: initializing and configuring the thread pool; if the thread pool is successfully initialized, determining whether the thread pool is busy; and if all threads in the thread pool are executing tasks and the queue corresponding to the thread pool is full, determining that the thread pool is busy.
[0014] According to another aspect of an embodiment of the present invention, a message gateway is also provided, including: the message gateway includes: an acquisition unit, used to acquire a message, and determine the target data in the message and the type of the message, the target data being the data transmitted by the message; a first determination unit, used to determine the target service unit and the target service code according to a configuration file and the type of the message, the configuration file being a pre-configured file, the target service code being a unique identifier of the target service, and the target service being one of multiple services in the target service unit; a first sending unit, used to send a request message carrying the target service code and the target data to the target service unit, so that the target service unit determines the corresponding target service according to the target service code, and uses the target service to process the target data.
[0015] According to another aspect of the embodiments of the present invention, a computer-readable storage medium is provided, wherein the computer-readable storage medium includes a stored program, wherein the program executes any one of the methods described.
[0016] According to yet another aspect of the embodiments of the present invention, a processor is provided, wherein the processor is used to run a program, wherein any one of the methods is executed when the program is run.
[0017] According to one aspect of an embodiment of the present invention, a message processing system is also provided, comprising: one or more processors, a memory and one or more programs, wherein the one or more programs are stored in the memory and are configured to be executed by the one or more processors, and the one or more programs include methods for executing any one of the described methods.
[0018] In the embodiment of the present invention, in the unitized processing method of the message, first, the message is obtained, and the target data in the message and the type of the message are determined according to the obtained message; then, the target service unit and the target service code are determined according to the configuration file and the type of the message; finally, the request message carrying the target service code and the target data is sent to the target service unit, and the target service unit can determine the corresponding target service according to the target service code, and use the target service to process the target data, wherein the configuration file is a pre-configured file, the target service code is a unique identifier of the target service, and the target service is one of the multiple services in the target service unit. In this scheme, according to the configuration file and the type of the obtained message, the target service unit and the target service code corresponding to the message are determined, and then the request message carrying the target data and the target service code is sent to the target service unit, that is, the unitized processing of the message content is realized, the execution rate of the message content is guaranteed to be high, and the concurrent processing capability of the system is improved, thereby solving the problem of difficulty in unitizing the message content in the prior art. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] The drawings constituting part of the present application are used to provide a further understanding of the present application. The exemplary embodiments and descriptions of the present application are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:
[0020] Figure 1 A schematic diagram showing a method for unitizing message processing according to an embodiment of the present application is shown;
[0021] Figure 2 A schematic diagram of a message gateway according to an embodiment of the present application is shown;
[0022] Figure 3 A processing flow chart of a message gateway according to the present application is shown. DETAILED DESCRIPTION
[0023] It should be noted that, in the absence of conflict, the embodiments and features in the embodiments of the present application can be combined with each other. The present application will be described in detail below with reference to the accompanying drawings and in combination with the embodiments.
[0024] In order to enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of this application.
[0025] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequential order. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present application described here. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0026] For the convenience of description, some nouns or terms involved in the embodiments of the present application are explained below:
[0027] Thread pool: A collection of multiple threads is called a thread pool. Using a thread pool can greatly improve performance. The thread pool creates a large number of idle threads when the system starts. When the program passes a task to the thread pool, the thread pool will start a thread to execute the task. After the execution is completed, the thread will not die, but return to the thread pool again and become idle, waiting to execute the next task.
[0028] As mentioned in the background technology, it is difficult to perform unitized processing on message contents in the prior art. In order to solve the above problem, in a typical implementation of the present application, a unitized processing method for messages, a message gateway, a computer-readable storage medium, a processor and a message processing system are provided.
[0029] According to an embodiment of the present application, a unitized message processing method is provided.
[0030] Figure 1 1 is a flowchart of a method for unitizing and processing messages according to an embodiment of the present application. Figure 1 As shown, the method can be applied to a message gateway, and the method comprises the following steps:
[0031] Step S101, obtaining a message, and determining target data in the message and the type of the message, wherein the target data is data transmitted by the message;
[0032] Step S102, determining a target service unit and a target service code according to a configuration file and the type of the message, wherein the configuration file is a pre-configured file, the target service code is a unique identifier of a target service, and the target service is one of a plurality of services in the target service unit;
[0033] Step S103, sending a request message carrying the target service code and the target data to the target service unit, so that the target service unit determines the corresponding target service according to the target service code, and processes the target data using the target service.
[0034] In the unitized processing method of the above-mentioned message, first, the message is obtained, and the target data in the message and the type of the message are determined according to the obtained message; then, the target service unit and the target service code are determined according to the configuration file and the type of the message; finally, the request message carrying the target service code and the target data is sent to the target service unit, and the target service unit can determine the corresponding target service according to the target service code, and use the target service to process the target data, wherein the configuration file is a pre-configured file, the target service code is the unique identifier of the target service, and the target service is one of the multiple services in the target service unit. In this scheme, according to the configuration file and the type of the obtained message, the target service unit and the target service code corresponding to the message are determined, and then the request message carrying the target data and the target service code is sent to the target service unit, that is, the unitized processing of the message content is realized, the execution rate of the message content is guaranteed to be high, and the concurrent processing capability of the system is improved, thereby solving the problem of difficulty in unitizing the message content in the prior art.
[0035] In actual application, the types of the above messages can be file-type messages, data-type messages, response-type messages, etc. In addition, in this solution, the target data and target service code can be encapsulated into a request message and the request message can be sent to the target service unit, and the target service unit determines the corresponding target service according to the target service code carried in the request message, which ensures that the target service unit can easily identify the request message and can execute the request message in a timely manner.
[0036] Specifically, when the type of the above message is a file-related message, the above message may include the type of file, the time when the file is uploaded, the address where the file is located, and the like.
[0037] In a specific embodiment of the present application, messages may also be pulled from an Enterprise Data Bus (EDB) by creating an EDB message receiver.
[0038] It should be noted that the steps shown in the flowcharts of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and that, although a logical order is shown in the flowcharts, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0039] In order to determine the target service unit and the target service code more simply and efficiently, in an embodiment of the present application, the target service unit and the target service code are determined according to the configuration file and the type of the above-mentioned message, including: determining the above-mentioned configuration file according to the type of the above-mentioned message; determining the above-mentioned target service unit and the above-mentioned target service code corresponding to the above-mentioned message according to the above-mentioned configuration file.
[0040] In a specific embodiment of the present application, the above configuration file may be pre-stored in the message gateway.
[0041] In another embodiment of the present application, obtaining a message includes: obtaining the above message when the thread pool is not busy; pausing obtaining the above message and controlling the above thread pool to sleep when the thread pool is busy or the above message in the enterprise data bus is empty, thereby reducing system consumption.
[0042] In a specific embodiment of the present application, the thread pool may also be controlled to sleep according to a set time interval.
[0043] In another embodiment of the present application, determining the target data in the message and the type of the message includes: parsing the message to obtain the target data, the type of the message and the unique identifier of the message; determining whether the message has been stored in the database according to the unique identifier of the message; if the message has been stored in the database, not storing the message in the database, and sending a first receipt message to the enterprise data bus; if the message has not been stored in the database, storing the message in the database, and sending a second receipt message to the enterprise data bus. In this embodiment, according to the unique identifier of the determined message, it is determined whether the message has been stored in the database. If the message has been stored in the database, in order to ensure that the message is not stored in the database repeatedly, the message is not stored in the database, and the first receipt message is sent to the enterprise data bus. If the message has not been stored in the database, the message is stored in the database to prevent the message from being lost, and the second receipt message is sent to the enterprise data bus. This ensures that the enterprise data bus can know whether the message has been consumed in a relatively timely manner, thereby solving the problem of message reliability.
[0044] Specifically, if it is determined based on the unique identifier of the message that the message has been stored in the database, it means that the enterprise data bus has not deleted the message in time, which will result in the duplicate message being received again. Therefore, in this case, this solution will reply with a first receipt message to the enterprise data bus. The first receipt message is used to indicate that the message is repeated and the message can be deleted. If it is determined based on the unique identifier of the message that the message has not been stored in the database, this solution will store the message in the database and reply with a second receipt message to the enterprise data bus. The second receipt message is used to indicate that the message has been stored in the database and the message can be deleted. In this way, the messages can be managed more efficiently, and it is also ensured that the messages stored in the database will be executed later, further ensuring a high execution rate of the messages.
[0045] In order to facilitate the viewing of the status of messages in the database and to more conveniently manage the messages in the data, in another embodiment of the present application, after the target service is used to process the target data, the method further includes: receiving a response message, the response message being used to characterize the processing of the target data by the target service, the processing status including one of the following: successful execution, unsuccessful execution; and updating the status of the message stored in the database according to the response message.
[0046] Specifically, the status of the message stored in the database can be divided into unexecuted and executed, and the status of the executed message can be further divided into unsuccessfully executed and successfully executed.
[0047] In one embodiment of the present application, the method further includes: polling the status of all the messages in the database according to a predetermined time interval, and determining the number of unsuccessful executions of the messages that have not been successfully executed; when the number of unsuccessful executions is less than or equal to a predetermined value, encapsulating the message into the request message again, and sending the re-encapsulated request message to the target service unit; when the number of unsuccessful executions is greater than the predetermined value, updating the status of the message to execution failure. In this embodiment, when the number of unsuccessful executions is less than or equal to a predetermined value, the message that has not been successfully executed is encapsulated into a request message again and sent to the target service unit, so that the message that has not been successfully executed can be executed again in time, and when the number of unsuccessful executions is greater than a predetermined value, the status of the message that has not been successfully executed is updated to execution failure, that is, the message that can be executed abnormally can be obtained regularly, and the abnormal message can be covered, which further ensures that the message stored in the database will be executed, and further ensures that the execution rate of the message is high.
[0048] In actual application, the above-mentioned predetermined time interval and the above-mentioned predetermined value can be adjusted according to actual conditions, and the present application does not impose specific restrictions on the above-mentioned predetermined time interval and the above-mentioned predetermined value.
[0049] In a specific embodiment of the present application, when the number of unsuccessful executions is greater than a predetermined value, the status of the message that has not been successfully executed is updated to execution failure, and the message determined to be execution failure can be processed manually later.
[0050] In another embodiment of the present application, before obtaining a message and determining the target data in the message and the type of the message, the method further includes: initializing and configuring the thread pool; when the thread pool is successfully initialized, determining whether the thread pool is busy, and when all threads in the thread pool are executing tasks and the queue corresponding to the thread pool is full, determining that the thread pool is busy, and subsequently, when the thread pool is busy, controlling the thread pool to suspend obtaining messages and controlling the thread pool to sleep, further ensuring that the system consumption is low.
[0051] In a specific embodiment of the present application, when the thread pool fails to be initialized, a message of "thread pool information acquisition failure" is thrown so that the developer or manager can handle the exception in time.
[0052] The embodiment of the present application also provides a message gateway. It should be noted that the message gateway of the embodiment of the present application can be used to execute the unitized processing method for messages provided in the embodiment of the present application. The message gateway provided in the embodiment of the present application is introduced below.
[0053] Figure 2 Schematic diagram of a message gateway according to an embodiment of the present application. Figure 2 As shown, the message gateway includes:
[0054] The acquisition unit 10 is used to acquire a message and determine target data in the message and the type of the message, wherein the target data is data transmitted by the message;
[0055] A first determining unit 20 is used to determine a target service unit and a target service code according to a configuration file and the type of the message, wherein the configuration file is a pre-configured file, the target service code is a unique identifier of a target service, and the target service is one of a plurality of services in the target service unit;
[0056] The first sending unit 30 is used to send a request message carrying the target service code and the target data to the target service unit, so that the target service unit determines the corresponding target service according to the target service code and processes the target data using the target service.
[0057] In the above-mentioned message gateway, the acquisition unit is used to acquire the message and determine the target data in the message and the type of the message, the target data being the data transmitted by the message; the first determination unit is used to determine the target service unit and the target service code according to the configuration file and the type of the message, the configuration file is a pre-configured file, the target service code is the unique identifier of the target service, and the target service is one of the multiple services in the target service unit; the first sending unit is used to send the request message carrying the target service code and the target data to the target service unit, so that the target service unit determines the corresponding target service according to the target service code, and uses the target service to process the target data. In this scheme, according to the configuration file and the type of the acquired message, the target service unit and the target service code corresponding to the message are determined, and then the request message carrying the target data and the target service code is sent to the target service unit, that is, the unitized processing of the message content is realized, the execution rate of the message content is guaranteed to be high, and the concurrent processing capability of the system is improved, thereby solving the problem of difficulty in unitized processing of the message content in the prior art.
[0058] In actual application, the types of the above messages can be file-type messages, data-type messages, response-type messages, etc. In addition, in this solution, the target data and target service code can be encapsulated into a request message and the request message can be sent to the target service unit, and the target service unit determines the corresponding target service according to the target service code carried in the request message, which ensures that the target service unit can easily identify the request message and can execute the request message in a timely manner.
[0059] Specifically, when the type of the above message is a file-related message, the above message may include the type of file, the time when the file is uploaded, the address where the file is located, and the like.
[0060] In a specific embodiment of the present application, messages may also be pulled from an Enterprise Data Bus (EDB) by creating an EDB message receiver.
[0061] In order to determine the target service unit and the target service code more simply and efficiently, in an embodiment of the present application, the above-mentioned first determination unit includes a first determination module and a second determination module, wherein the above-mentioned first determination module is used to determine the above-mentioned configuration file according to the type of the above-mentioned message; the above-mentioned second determination module is used to determine the above-mentioned target service unit and the above-mentioned target service code corresponding to the above-mentioned message according to the above-mentioned configuration file.
[0062] In a specific embodiment of the present application, the above configuration file may be pre-stored in the message gateway.
[0063] In another embodiment of the present application, the acquisition unit includes an acquisition module and a control module, wherein the acquisition module is used to acquire the message when the thread pool is not busy; the control module is used to suspend acquisition of the message and control the thread pool to sleep when the thread pool is busy or the message in the enterprise data bus is empty, thereby reducing system consumption.
[0064] In a specific embodiment of the present application, the thread pool may also be controlled to sleep according to a set time interval.
[0065] In another embodiment of the present application, the acquisition unit further includes a parsing module, a third determination module, a first sending module and a second sending module, wherein the parsing module is used to parse the message to obtain the target data, the type of the message and the unique identifier of the message; the third determination module is used to determine whether the message has been stored in the database according to the unique identifier of the message; the first sending module is used to not store the message in the database if the message has been stored in the database, and send a first receipt message to the enterprise data bus; the second sending module is used to store the message in the database if the message has not been stored in the database, and send a second receipt message to the enterprise data bus. In this embodiment, based on the determined unique identifier of the message, it is determined whether the message has been stored in the database. If the message has been stored in the database, in order to ensure that the message is not stored in the database repeatedly, the message is not stored in the database, and a first receipt message is sent to the enterprise data bus. If the message is not stored in the database, the message is stored in the database to prevent the message from being lost, and a second receipt message is sent to the enterprise data bus. This ensures that the enterprise data bus can know whether the message has been consumed in a relatively timely manner, thereby solving the problem of message reliability.
[0066] Specifically, if it is determined based on the unique identifier of the message that the message has been stored in the database, it means that the enterprise data bus has not deleted the message in time, which will result in the duplicate message being received again. Therefore, in this case, this solution will reply with a first receipt message to the enterprise data bus. The first receipt message is used to indicate that the message is repeated and the message can be deleted. If it is determined based on the unique identifier of the message that the message has not been stored in the database, this solution will store the message in the database and reply with a second receipt message to the enterprise data bus. The second receipt message is used to indicate that the message has been stored in the database and the message can be deleted. In this way, the messages can be managed more efficiently, and it is also ensured that the messages stored in the database will be executed later, further ensuring a high execution rate of the messages.
[0067] In order to facilitate the viewing of the status of messages in the database and to more conveniently manage the messages in the data, in another embodiment of the present application, the message gateway also includes a receiving unit and a first update unit, wherein the receiving unit is used to receive a response message after the target service is used to process the target data, and the response message is used to characterize the processing of the target data by the target service, and the processing status includes one of the following: successful execution, unsuccessful execution; the first update unit is used to update the status of the message stored in the database according to the response message.
[0068] Specifically, the status of the message stored in the database can be divided into unexecuted and executed, and the status of the executed message can be further divided into unsuccessfully executed and successfully executed.
[0069] In one embodiment of the present application, the message gateway further includes a second determination unit, a second sending unit and a second updating unit, wherein the second determination unit is used to poll the status of all the messages in the database according to a predetermined time interval, and determine the number of unsuccessful executions of the messages that have not been successfully executed; the second sending unit is used to encapsulate the message into the request message again when the number of unsuccessful executions is less than or equal to a predetermined value, and send the re-encapsulated request message to the target service unit; the second updating unit is used to update the status of the message to execution failure when the number of unsuccessful executions is greater than the predetermined value. In this embodiment, when the number of unsuccessful executions is less than or equal to a predetermined value, the message that has not been successfully executed is encapsulated into a request message again and sent to the target service unit, so that the message that has not been successfully executed can be executed again in time, and when the number of unsuccessful executions is greater than a predetermined value, the status of the message that has not been successfully executed is updated to execution failure, that is, the message that can be executed abnormally can be obtained regularly, and the abnormal message can be covered, which further ensures that the message stored in the database will be executed, and further ensures that the execution rate of the message is high.
[0070] In actual application, the above-mentioned predetermined time interval and the above-mentioned predetermined value can be adjusted according to actual conditions, and the present application does not impose specific restrictions on the above-mentioned predetermined time interval and the above-mentioned predetermined value.
[0071] In a specific embodiment of the present application, when the number of unsuccessful executions is greater than a predetermined value, the status of the message that has not been successfully executed is updated to execution failure, and the message determined to be execution failure can be processed manually later.
[0072] In another embodiment of the present application, the message gateway further includes a configuration unit and a third determination unit, wherein the configuration unit is used to initialize and configure the thread pool before obtaining a message and determining the target data in the message and the type of the message; the third determination unit is used to determine whether the thread pool is busy when the thread pool is initialized successfully, and to determine that the thread pool is busy when all threads in the thread pool are executing tasks and the queue corresponding to the thread pool is full; subsequently, when the thread pool is busy, the thread pool is controlled to suspend obtaining messages and to sleep, thereby further ensuring that the system consumption is low.
[0073] In a specific embodiment of the present application, when the thread pool fails to be initialized, a message of "thread pool information acquisition failure" is thrown so that the developer or manager can handle the exception in time.
[0074] In order to enable those skilled in the art to more clearly understand the technical solution of the present application, the following will be described in conjunction with specific embodiments:
[0075] Example
[0076] like Figure 3 As shown, first, after the application is successfully started, the thread pool is initialized according to the configuration. If the thread pool is successfully initialized, it is reserved for use; if the thread pool fails to be initialized, the message "thread pool information acquisition failure" is thrown; secondly, it is judged whether the thread pool is busy. If the thread pool is busy, new message processing is suspended. After there are extra threads, the processing flow is started again and the thread pool is controlled to sleep. If the thread pool is not busy, messages continue to be received; thirdly, it is judged whether the message queue is empty. If the message queue is empty, the queue is controlled to sleep. If the message queue is not empty, the message is parsed to obtain the unique identifier of the message. According to the unique identifier of the message, it is determined whether the message has been stored. If the message has been stored, the first receipt message is sent to the enterprise data bus. If the message has not been stored, the second receipt message is sent to the enterprise data bus (in order to ensure that the flowchart is clear and concise, Figure 3 In the example, the first receipt message and the second receipt message are both represented as receipt messages), after which the message stored in the database is transferred to the asynchronous thread for processing, and then the target service unit and the target service code are determined according to the configuration file and the message type pre-stored in the message gateway, and are encapsulated as a request message, and then the request message is sent to the target service unit, so that the target service unit determines the target service according to the target service code in the request message, and executes the target data carried in the request message, and finally, receives the response message, and updates the message processing status according to the response message. In addition, the message gateway in this scheme also has a built-in polling service, which will regularly check the status of the messages in the database. If there are messages that have not been successfully executed, they will be re-encapsulated into request messages and sent to the target service unit for processing. If the processing reaches the predetermined value and is still unsuccessful, the status of the message will be updated to execution failure, and the offline manual process will be used for subsequent processing.
[0077] The unitized processing device for the above-mentioned message includes a processor and a memory. The above-mentioned acquisition unit, the first determination unit and the first sending unit are all stored in the memory as program units, and the processor executes the above-mentioned program units stored in the memory to realize corresponding functions.
[0078] The processor includes a kernel, which retrieves the corresponding program unit from the memory. One or more kernels can be provided, and the problem of difficulty in unitizing message content in the prior art can be solved by adjusting kernel parameters.
[0079] The memory may include non-permanent memory in a computer-readable medium, random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM, and the memory includes at least one memory chip.
[0080] An embodiment of the present invention provides a storage medium on which a program is stored. When the program is executed by a processor, the unitized processing method of the above-mentioned message is implemented.
[0081] An embodiment of the present invention provides a processor, and the processor is used to run a program, wherein the unitized processing method of the message is executed when the program is running.
[0082] In a typical embodiment of the present application, a message processing system is also provided, comprising: one or more processors, a memory and one or more programs, wherein the one or more programs are stored in the memory and are configured to be executed by the one or more processors, and the one or more programs include methods for executing any one of the above methods.
[0083] The message processing system can execute the unitized processing method of the message. In the unitized processing method of the message, first, the message is obtained, and the target data in the message and the type of the message are determined according to the obtained message; then, the target service unit and the target service code are determined according to the configuration file and the type of the message; finally, the request message carrying the target service code and the target data is sent to the target service unit, and the target service unit can determine the corresponding target service according to the target service code, and use the target service to process the target data, wherein the configuration file is a pre-configured file, the target service code is a unique identifier of the target service, and the target service is one of the multiple services in the target service unit. In this scheme, according to the configuration file and the type of the obtained message, the target service unit and the target service code corresponding to the message are determined, and then the request message carrying the target data and the target service code is sent to the target service unit, that is, the unitized processing of the message content is realized, the execution rate of the message content is guaranteed to be high, and the concurrent processing capability of the system is improved, thereby solving the problem of difficulty in unitized processing of the message content in the prior art.
[0084] An embodiment of the present invention provides a device, the device including a processor, a memory, and a program stored in the memory and executable on the processor, and when the processor executes the program, at least the following steps are implemented:
[0085] Step S101, obtaining a message, and determining target data in the message and the type of the message, wherein the target data is data transmitted by the message;
[0086] Step S102, determining a target service unit and a target service code according to a configuration file and the type of the message, wherein the configuration file is a pre-configured file, the target service code is a unique identifier of a target service, and the target service is one of a plurality of services in the target service unit;
[0087] Step S103, sending a request message carrying the target service code and the target data to the target service unit, so that the target service unit determines the corresponding target service according to the target service code, and processes the target data using the target service.
[0088] The devices in this article can be servers, PCs, PADs, mobile phones, etc.
[0089] The present application also provides a computer program product, which, when executed on a data processing device, is suitable for executing a program for initializing at least the following method steps:
[0090] Step S101, obtaining a message, and determining target data in the message and the type of the message, wherein the target data is data transmitted by the message;
[0091] Step S102, determining a target service unit and a target service code according to a configuration file and the type of the message, wherein the configuration file is a pre-configured file, the target service code is a unique identifier of a target service, and the target service is one of a plurality of services in the target service unit;
[0092] Step S103, sending a request message carrying the target service code and the target data to the target service unit, so that the target service unit determines the corresponding target service according to the target service code, and processes the target data using the target service.
[0093] In the above embodiments of the present invention, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0094] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. Among them, the device embodiments described above are only schematic. For example, the division of the above-mentioned units can be a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of units or modules, which can be electrical or other forms.
[0095] The units described above as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple units. Some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.
[0096] In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0097] If the above-mentioned integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server or a network device, etc.) to perform all or part of the steps of the above-mentioned methods of each embodiment of the present invention. The aforementioned storage medium includes: U disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), mobile hard disk, magnetic disk or optical disk and other media that can store program codes.
[0098] From the above description, it can be seen that the above embodiments of the present application achieve the following technical effects:
[0099] 1) In the unitized processing method of the message of the present application, first, the message is obtained, and the target data in the message and the type of the message are determined according to the obtained message; then, the target service unit and the target service code are determined according to the configuration file and the type of the message; finally, the request message carrying the target service code and the target data is sent to the target service unit, and the target service unit can determine the corresponding target service according to the target service code, and use the target service to process the target data, wherein the configuration file is a pre-configured file, the target service code is the unique identifier of the target service, and the target service is one of the multiple services in the target service unit. In this scheme, according to the configuration file and the type of the obtained message, the target service unit and the target service code corresponding to the message are determined, and then the request message carrying the target data and the target service code is sent to the target service unit, that is, the unitized processing of the message content is realized, the execution rate of the message content is guaranteed to be high, and the concurrent processing capability of the system is improved, thereby solving the problem of difficulty in unitizing the message content in the prior art.
[0100] 2) In the message gateway of the present application, the acquisition unit is used to acquire the message and determine the target data in the message and the type of the message. The target data is the data transmitted by the message. The first determination unit is used to determine the target service unit and the target service code according to the configuration file and the type of the message. The configuration file is a pre-configured file. The target service code is the unique identifier of the target service. The target service is one of the multiple services in the target service unit. The first sending unit is used to send the request message carrying the target service code and the target data to the target service unit, so that the target service unit determines the corresponding target service according to the target service code, and uses the target service to process the target data. In this scheme, according to the configuration file and the type of the acquired message, the target service unit and the target service code corresponding to the message are determined, and then the request message carrying the target data and the target service code is sent to the target service unit, that is, the unitized processing of the message content is realized, the execution rate of the message content is guaranteed to be high, and the concurrent processing capability of the system is improved, thereby solving the problem of difficulty in unitized processing of the message content in the prior art.
[0101] 3) The message processing system of the present application can execute the unitized processing method of the above-mentioned message. In the unitized processing method of the above-mentioned message, first, the message is obtained, and the target data in the above-mentioned message and the type of the above-mentioned message are determined according to the obtained message; then, the target service unit and the target service code are determined according to the configuration file and the type of the above-mentioned message; finally, the request message carrying the above-mentioned target service code and the above-mentioned target data is sent to the above-mentioned target service unit, and the above-mentioned target service unit can determine the corresponding target service according to the target service code, and use the above-mentioned target service to process the above-mentioned target data, wherein the above-mentioned configuration file is a pre-configured file, the above-mentioned target service code is the unique identifier of the target service, and the above-mentioned target service is one of the multiple services in the above-mentioned target service unit. In this scheme, according to the configuration file and the type of the obtained message, the target service unit and the target service code corresponding to the message are determined, and then the request message carrying the target data and the target service code is sent to the target service unit, that is, the unitized processing of the message content is realized, the execution rate of the message content is guaranteed to be high, and the concurrent processing capability of the system is improved, thereby solving the problem of difficulty in unitizing the message content in the prior art.
[0102] The above are only preferred embodiments of the present application and are not intended to limit the present application. For those skilled in the art, the present application may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application shall be included in the protection scope of the present application.
Claims
1. A unitized message processing method, characterized in that: include: Acquire a message, and determine target data in the message and the type of the message, wherein the target data is data transmitted by the message; Determine a target service unit and a target service code according to a configuration file and the type of the message, wherein the configuration file is a pre-configured file, the target service code is a unique identifier of a target service, and the target service is one of a plurality of services in the target service unit; Sending a request message carrying the target service code and the target data to the target service unit, so that the target service unit determines the corresponding target service according to the target service code, and uses the target service to process the target data; Determining target data in the message and the type of the message includes: Parsing the message to obtain the target data, the type of the message and the unique identifier of the message in the message; Determining whether the message has been stored in the database according to the unique identifier of the message; In the case where the message has been stored in the database, not storing the message in the database, and sending a first receipt message to the enterprise data bus; If the message is not stored in the database, the message is stored in the database, and a second receipt message is sent to the enterprise data bus.
2. The method according to claim 1, characterized in that Determine the target service unit and the target service code according to the configuration file and the type of the message, including: Determining the configuration file according to the type of the message; The target service unit and the target service code corresponding to the message are determined according to the configuration file.
3. The method according to claim 1, characterized in that: Get messages, including: When the thread pool is not busy, obtaining the message; When the thread pool is busy or the message in the enterprise data bus is empty, the acquisition of the message is suspended and the thread pool is controlled to sleep.
4. The method according to claim 1, characterized in that After the target service is used to process the target data, the method further includes: receiving a response message, wherein the response message is used to indicate a processing status of the target service on the target data, wherein the processing status includes one of the following: successful execution and unsuccessful execution; According to the response message, the status of the message stored in the database is updated.
5. The method according to claim 4, characterized in that The method further comprises: polling the status of all the messages in the database according to a predetermined time interval, and determining the number of unsuccessful executions of the messages that were not successfully executed; When the number of unsuccessful executions is less than or equal to a predetermined value, encapsulating the message into the request message again, and sending the re-encapsulated request message to the target service unit; When the number of unsuccessful executions is greater than the predetermined value, the status of the message is updated to execution failure.
6. The method according to claim 1, characterized in that Before obtaining a message and determining target data in the message and the type of the message, the method further includes: Initialize and configure the thread pool; When the thread pool is successfully initialized, it is determined whether the thread pool is busy. When all threads in the thread pool are executing tasks and the queue corresponding to the thread pool is full, it is determined that the thread pool is busy.
7. A message gateway, characterized in that: The message gateway comprises: an acquisition unit, configured to acquire a message and determine target data in the message and a type of the message, wherein the target data is data transmitted by the message; A first determining unit, configured to determine a target service unit and a target service code according to a configuration file and a type of the message, wherein the configuration file is a pre-configured file, the target service code is a unique identifier of a target service, and the target service is one of a plurality of services in the target service unit; A first sending unit, configured to send a request message carrying the target service code and the target data to the target service unit, so that the target service unit determines the corresponding target service according to the target service code, and uses the target service to process the target data; The acquisition unit includes: a parsing module, a third determining module, a first sending module and a second sending module. The parsing module is used to parse the message to obtain the target data in the message, the type of the message and the unique identifier of the message; The third determination module is used to determine whether the message has been stored in the database according to the unique identifier of the message; The first sending module is used for not storing the message in the database and sending a first receipt message to the enterprise data bus when the message has been stored in the database; The second sending module is used for storing the message in the database when the message has not been stored in the database, and sending a second receipt message to the enterprise data bus.
8. A computer-readable storage medium, characterized in that: The computer-readable storage medium includes a stored program, wherein: The program executes the method according to any one of claims 1 to 6.
9. A processor, characterized in that: The processor is used to run a program, wherein the program executes the method according to any one of claims 1 to 6 when running.
10. A message processing system, characterized in that: include: One or more processors, a memory, and one or more programs, wherein the one or more programs are stored in the memory and are configured to be executed by the one or more processors, and the one or more programs include methods for executing any one of claims 1 to 6.
Citation Information
Patent Citations
Message processing method, device and system, electronic device and storage medium
CN111786886A
Message queue-based request processing method, apparatus and device, and storage medium
WO2020062793A1
