Message sending method, electronic device, storage medium and program product
By identifying and sorting messages, we ensure that messages are received and processed in the order of consumption on the server side, which solves the problem of message order errors caused by network fluctuations and improves the processing efficiency of message producers.
Patent Information
- Application Number
- CN202411336791.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-24
- Publication Date
- 2024-12-13
AI Technical Summary
During the message sending process, messages that need to be processed in a specific order are incorrect in the server's receiving order due to network fluctuations, resulting in incomplete or incorrect in sequence when consumers process messages.
By intercepting messages sent by the producer, identifying whether they are sequential messages, and cache the sequential messages of the same consumption batch to the queue of messages to be sent. After all messages are added, sorting them in preset order, ensuring that messages are sent continuously to the server in consumption order. .
Ensure that messages are received and processed in the order of consumption on the server side, avoid incomplete messages or order errors, simplify producer business processing processes, and improve producer processing efficiency.
Smart Images

Figure CN119135761A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of computer technology, and in particular to a message sending method, an electronic device, a storage medium, and a computer program product. Background Art
[0002] In many website platforms, there are scenarios where different terminals or components interact with each other. Among them, the terminal or component that produces messages is called a producer, and the terminal or component that receives messages is called a consumer. In some application scenarios, the producer sends the message to the server, and the server pushes the message to the consumer, or the consumer actively obtains the message from the server.
[0003] However, some types of messages need to be processed in a specific order. Usually, the messages that arrive at the server first will be consumed by the consumer first. Therefore, for such messages that need to be processed in a specific order, the producer is often required to strictly control the order in which they are sent to the server to ensure that the server receives such messages in the order in which they are consumed. Once network fluctuations occur, problems such as message sending failure and message delay may occur, causing the server to not receive messages in a specific order, resulting in incomplete messages and incorrect message order when consumers process messages. Summary of the invention
[0004] In order to solve one of the above technical problems, the present disclosure provides a message sending method, an electronic device, a storage medium and a computer program product.
[0005] The first aspect of the present disclosure provides a message sending method, including: obtaining a message to be sent; identifying whether the message to be sent is a sequential message, wherein the sequential messages of the same consumption batch have a preset consumption order; adding the identified sequential message to a queue of messages to be sent, and judging whether the sequential messages of the same consumption batch are all added to the queue of messages to be sent; in response to a judgment signal that the sequential messages of the same consumption batch are all added to the queue of messages to be sent, sorting the sequential messages in the queue of messages to be sent according to the consumption order to obtain a sorted queue; and continuously sending the sequential messages in the sorted queue to a target message partition according to the consumption order. In at least one optional implementation, obtaining the message to be sent includes: detecting whether an initial message generated by a message producer is sent from the message producer, and intercepting the initial message when the initial message is sent to obtain the message to be sent.
[0006] In at least one optional embodiment, identifying whether the message to be sent is a sequential message includes: obtaining a preset message topic, each of the preset message topics including multiple sequential messages of the same consumption batch and the respective consumption order of the multiple sequential messages of the same consumption batch; obtaining the message topic of the message to be sent, and determining whether the message topic of the message to be sent is the preset message topic; and in response to a judgment signal that the message topic of the message to be sent is the preset message topic, identifying the message to be sent as the sequential message in the corresponding preset message topic.
[0007] In at least one optional implementation, identifying whether the message to be sent is a sequential message includes: performing semantic identification on the message to be sent to determine whether the message to be sent is a previous process message or a following process message; and in response to a judgment signal that the message to be sent is a previous process message or a following process message, identifying the message to be sent as the sequential message.
[0008] In at least one optional embodiment, the identified sequential message is added to a queue of messages to be sent, comprising: obtaining a message subject of the sequential message; determining whether there is a created queue of messages to be sent corresponding to the message subject of the sequential message; in response to a determination signal that there is a created queue of messages to be sent corresponding to the message subject of the sequential message, adding the sequential message to the queue of messages to be sent corresponding to the message subject of the sequential message; and in response to a determination signal that there is no created queue of messages to be sent corresponding to the message subject of the sequential message, creating a new queue of messages to be sent and adding the sequential message to the new queue of messages to be sent, wherein the new queue of messages to be sent corresponds to the message subject of the sequential message.
[0009] In at least one optional implementation, determining whether the sequential messages of the same consumption batch are all added to the queue of messages to be sent includes: in response to a signal that the sequential messages are added to the queue of messages to be sent, obtaining a batch identifier and a sequence identifier of the sequential messages, wherein the batch identifier representing the same consumption batch corresponds to a plurality of sequence identifiers; determining whether all of the plurality of sequence identifiers corresponding to the batch identifier are obtained; and in response to a determination signal that all of the plurality of sequence identifiers corresponding to the batch identifier have been obtained, obtaining a determination result that the sequential messages of the same consumption batch are all added to the queue of messages to be sent.
[0010] In at least one optional implementation, the sequential messages in the message queue to be sent are sorted according to the order of consumption to obtain a sorted queue, including: based on the consumption order represented by the sequence identifiers of each of the sequential messages in the message queue to be sent, sorting each of the sequential messages in the order of consumption from first to last to obtain the sorted queue.
[0011] In at least one optional implementation, the sequential messages in the sorted queue are continuously sent to the target message partition in the order of consumption, including: obtaining the number of multiple partitions to be selected; obtaining the number of the sorted queues that have been sent; performing a remainder calculation on the number of partitions to be selected based on the number of the sorted queues that have been sent to obtain the i-th remainder value; and selecting the target message partition from the multiple partitions to be selected based on the i-th remainder value, and continuously sending the sequential messages in the i-th sorted queue to the target message partition in the order of consumption; wherein, i=j+1, j is the number of the sorted queues that have been sent.
[0012] In at least one optional implementation, the target message partition is selected from a plurality of the candidate partitions based on the i-th remainder value, and the sequential messages in the i-th sorted queue are continuously sent to the target message partition in the order of consumption, including: when the i-th remainder value is equal to m, selecting the m+1th candidate partition as the target message partition; wherein, 0≤m≤n-1, n is the number of the plurality of candidate partitions.
[0013] A second aspect of the present disclosure provides an electronic device, comprising: a memory storing execution instructions; and a processor executing the execution instructions stored in the memory, so that the processor executes a message sending processing method in any embodiment of the present disclosure.
[0014] A third aspect of the present disclosure provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the message sending method of any embodiment of the present disclosure is executed.
[0015] A fourth aspect of the present disclosure provides a computer program product, which includes a computer program. When the computer program is executed by a processor, the message sending method of any embodiment of the present disclosure is executed. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] The accompanying drawings illustrate exemplary embodiments of the present disclosure and together with the description serve to explain the principles of the present disclosure. These drawings are included to provide a further understanding of the present disclosure and are incorporated in and constitute a part of this specification.
[0017] Figure 1 It is a schematic diagram of a scenario in which a message sending method according to some embodiments of the present disclosure is used to send a message.
[0018] Figure 2 It is a flowchart of a message sending method according to some embodiments of the present disclosure.
[0019] Figure 3 It is a flowchart of a message sending method according to some embodiments of the present disclosure.
[0020] Figure 4 It is a flowchart of a message sending method according to some embodiments of the present disclosure.
[0021] Figure 5 It is a flowchart of a message sending method according to some embodiments of the present disclosure.
[0022] Figure 6 It is a flowchart of a message sending method according to some embodiments of the present disclosure.
[0023] Figure 7 It is a flowchart of a message sending method according to some embodiments of the present disclosure.
[0024] Figure 8 It is a schematic diagram of the structure of an electronic device according to some embodiments of the present disclosure. DETAILED DESCRIPTION
[0025] The present disclosure is further described in detail below in conjunction with the accompanying drawings and implementations. It is understood that the specific implementations described herein are only used to explain the relevant content, rather than to limit the present disclosure. It should also be noted that, for ease of description, only the parts related to the present disclosure are shown in the accompanying drawings.
[0026] It should be noted that, in the absence of conflict, the embodiments and features of the embodiments in the present disclosure can be combined with each other. The technical solution of the present disclosure will be described in detail below with reference to the accompanying drawings and in combination with the embodiments.
[0027] Unless otherwise specified, the exemplary embodiments / embodiments shown will be understood as providing exemplary features of various details of some ways in which the technical concept of the present disclosure can be implemented in practice. Therefore, unless otherwise specified, the features of the various embodiments / embodiments can be combined, separated, interchanged and / or rearranged without departing from the technical concept of the present disclosure.
[0028] The use of cross-hatching and / or shading in the accompanying drawings is generally used to make the boundaries between adjacent components clear. As such, unless otherwise specified, the presence or absence of cross-hatching or shading does not convey or indicate any preference or requirement for the specific materials, material properties, dimensions, proportions, commonalities between the components shown, and / or any other characteristics, attributes, properties, etc. of the components. In addition, in the accompanying drawings, the sizes and relative sizes of the components may be exaggerated for clarity and / or descriptive purposes. When the exemplary embodiments can be implemented differently, the specific process sequence can be performed in a different order than described. For example, two successively described processes can be performed substantially simultaneously or in an order opposite to the described order. In addition, the same figure numbers represent the same components.
[0029] When a component is referred to as being "on" or "over," "connected to," or "coupled to" another component, the component may be directly on, directly connected to, or directly coupled to the other component, or intervening components may be present. However, when a component is referred to as being "directly on," "directly connected to," or "directly coupled to" another component, there are no intervening components. For this purpose, the term "connected" may refer to a physical connection, an electrical connection, etc., with or without intervening components.
[0030] The terms used herein are for the purpose of describing specific embodiments, and are not intended to be restrictive. As used herein, unless the context clearly indicates otherwise, the singular forms "one (kind, person)" and "(the)" are also intended to include plural forms. In addition, when the terms "comprise" and / or "include" and their variations are used in this specification, it is explained that there are stated features, integral bodies, steps, operations, parts, assemblies and / or their groups, but one or more other features, integral bodies, steps, operations, parts, assemblies and / or their groups are not excluded from existence or addition. It should also be noted that, as used herein, the terms "substantially", "approximately" and other similar terms are used as approximate terms and not as degree terms, so that they are used to explain the inherent deviations of the measured values, calculated values and / or the values provided that will be recognized by those of ordinary skill in the art.
[0031] In the application scenario where the producer of a message produces a message and sends it to the server, and the consumer of the message obtains the message from the server, some types of messages need to be processed in a specific order, which is called sequential messages. Usually, sequential messages often require the producer to strictly control the order in which they are sent to the server, ensuring that the server receives the sequential messages in the order in which they are consumed, so as to ensure that the sequential messages are processed by the consumer in a specific order. Therefore, developers are usually required to customize the development of sequential messages for different business topics, and strictly control the order in which sequential messages are sent at the business logic level of the producer to ensure the order of the messages, which will result in low business processing efficiency for the producer. In addition, once the network fluctuates when the producer sends a message, problems such as message sending failure and delayed message sending may occur, resulting in the server not receiving the message in a specific order, which in turn leads to problems such as incomplete messages and incorrect message order when consumers process the messages.
[0032] Based on the above problems, the present disclosure provides a message sending method, and an electronic device 1000 (such as Figure 8 As shown). The electronic device 1000 may refer to a computer device. Furthermore, the electronic device 1000 and the message producer may be the same computer device; or, the electronic device 1000 and the message producer may be different computer devices, which is not limited here.
[0033] Figure 1 A schematic diagram of a scenario in which a message sending method according to an embodiment of the present disclosure is used to send a message is shown.
[0034] Figure 1 In the scenario shown, the message sending method can intercept the message sent by the message producer and identify whether the message is a sequential message. If it is not a sequential message, it is sent to the server immediately. If it is a sequential message, the sequential message is cached, and after all the sequential messages of the same consumption batch are cached, the sequential messages of the same consumption batch are sorted, and then sent to the server continuously in the order of consumption.
[0035] exist Figure 1 In the illustrated scenario, if the message sending method of the embodiment of the present disclosure is implemented by electronic device 1000, electronic device 1000 may be the same computer device as the producer of the message, or may be a different computer device from the producer of the message. If electronic device 1000 and the producer of the message are different computer devices, the electronic device is used to intercept the information sent by the producer of the message. If electronic device 1000 and the producer of the message are the same computer device, "intercepting the information sent by the producer" means obtaining the message to be sent and identifying whether the message is a sequential message when responding to the message sending instruction.
[0036] In this way, when the producer sends sequential messages, the sending order of the sequential messages may not be restricted by their consumption order. That is to say, the sequential messages that are processed first can be sent later, and the sequential messages that are processed later can be sent first. The message sending method of the embodiment of the present disclosure intercepts and sorts the sequential messages of the same batch, and sends them to the server together after sorting. Therefore, even if the producer does not send the sequential messages in the order in which the sequential messages are consumed, it can ensure that the server receives the sequential messages of the same batch in the order in which the sequential messages are consumed, so that the consumer can obtain the sequential messages of the batch from the server in the order in which they are consumed and process them in the order in which they are consumed. Therefore, the producer of the message does not need to carry out customized development of sequential messages for different business topics and control the sending order of sequential messages. The sequential messages can be sent when they are generated to improve the efficiency of the message producer in business processing.
[0037] Furthermore, the message sending method of the embodiment of the present disclosure can continuously send the sorted sequential messages of the same consumption batch to the server, so that the sequential messages of the same consumption batch can either be sent successfully at the same time or fail to be sent at the same time, thereby ensuring the integrity and sequentiality of the sequential messages.
[0038] In summary, the message sending method of the message sending method can sort the sequential messages of the same batch and send them to the server. In this way, the message producer does not need to control the sending order of the messages, and can ensure that the sequential messages are processed in the order of consumption, thereby simplifying the business processing flow of the message producer and improving the business processing efficiency of the message producer.
[0039] Figure 2 The flowchart of the message sending method M100 of the embodiment of the present disclosure is shown. The sending method M100 includes the following steps S110 to S150: S110: Obtain the message to be sent.
[0040] S120: Identify whether the message to be sent is a sequence message. Sequence messages in the same consumption batch have a preset consumption order.
[0041] S130: Add the identified sequenced messages to the queue of messages to be sent, and determine whether all sequenced messages of the same consumption batch are added to the queue of messages to be sent.
[0042] S140: In response to a determination signal that all sequenced messages of the same consumption batch are added to the queue of messages to be sent, the sequenced messages in the queue of messages to be sent are sorted according to the order of consumption to obtain a sorted queue.
[0043] S150: Send the sequenced messages in the sorted queue to the target message partition in succession according to the order of consumption.
[0044] In step S110, the message to be sent refers to a message generated by the producer of the message and sent to the server, which is sent from the producer but not sent to the server. The message to be sent needs to wait to be sent again, so it is called a message to be sent. For example, the producer of the message generates message A, and message A is specified by the sending instruction to be sent to the server. Before message A is sent to the server, it is intercepted and not sent to the server. This message A is the message to be sent. If message A has been sent to the server, then this message A is recorded as a sent message.
[0045] In step S120, the sequential message refers to a message that needs to be consumed (processed) by the message consumer in a specific order. For example, the messages generated in the transaction process of the trading platform include: order creation message, order payment message, order shipment message and order completion message. If the order completion message is processed before the order payment message, there is a logic problem. Therefore, the above-mentioned order creation message, order payment message, order shipment message and order completion message are sequential messages that need to be consumed and processed in a specific order.
[0046] In one example, a sequence message has corresponding sequence tag information, and whether the message to be sent is a sequence message can be determined by identifying whether the message has the corresponding sequence tag information.
[0047] In another example, there are multiple sequential messages corresponding to the same topic. A topic can refer to a specific business process, such as a specific transaction process, a specific calculation process, and so on. For multiple sequential messages corresponding to the same topic, the order of these sequential messages can be determined according to the process rules of the topic. For example, in the topic of a commodity transaction process, the order payment process must be after the order creation process, then it can be determined that the order payment message and the order creation message are sequential messages, and the order of the order payment message is after the order creation message. In other words, it is possible to determine whether the message to be sent is a message corresponding to a sequential process node in a topic.
[0048] In another example, the semantic information of the message to be sent can be obtained by performing natural language processing on the message to be sent, and it can be determined whether it is a sequential message based on the semantic information. For example, based on the semantic information of a message to be sent, it can be determined that the message to be sent has a logically corresponding previous or following message, and it is determined to be a sequential message. For example, a message to be sent is an order payment message. Based on the semantic information obtained by natural language processing, it can be determined that there should be an order creation process before the order payment, corresponding to the order creation message, and the order payment message is determined to be a sequential message.
[0049] In step S130, the queue of messages to be sent refers to a queue composed of cached messages to be sent. In one example, the acquired messages to be sent are cached in a data structure storage system, such as a Redis storage system. In a data structure storage system, a data structure output in the order of consumption is a queue. In other words, the queue of messages to be sent includes multiple messages to be sent cached in the data structure storage system, and these messages to be sent are output in the order of consumption. Accordingly, adding sequential messages to the queue of messages to be sent refers to caching sequential messages at the address of the queue of messages to be sent in the data structure storage system.
[0050] Sequential messages of the same consumption batch are messages in the same topic that belong to the same batch for consumption. For example, in the topic of commodity trading process, there may be multiple trading orders for the same type of commodity. Among them, the process from creation to completion of a trading order belongs to a batch of consumption process. Correspondingly, multiple sequential messages that need to be processed in the order of consumption in a process batch are sequential messages of the same consumption batch of the process batch.
[0051] In one example, different queues of messages to be sent correspond to different message batches (i.e., message consumption batches, referred to as message batches, the same below) of different message topics. That is, for the same message topic, the corresponding different message batches each correspond to a queue of messages to be sent. When it is identified that the message to be sent is a sequential message, the message topic and message batch corresponding to the sequential message are obtained. When the identified sequential message is added to the queue of messages to be sent, the queue of messages to be sent that is added is a message queue corresponding to the message topic and message batch of the sequential message.
[0052] Furthermore, in one example, the multiple sequential messages contained in each message batch correspond to different process nodes. According to whether the process nodes corresponding to the sequential messages in the message queue to be sent are complete, it can be determined whether the sequential messages of the same consumption batch are all added to the message queue to be sent. If the process nodes corresponding to each sequential message in the message queue to be sent can form a complete process batch, it can be determined that the sequential messages of the same consumption batch are all added to the message queue to be sent. On the contrary, if the process nodes corresponding to each sequential message in the message queue to be sent cannot form a complete process batch, it can be determined that the sequential messages of the same consumption batch have not all been added to the message queue to be sent.
[0053] In step S140, when it is determined that the sequenced messages of the same consumption batch are all added to the queue of messages to be sent, a corresponding judgment signal is generated, which indicates that the sequenced messages of the same consumption batch are all added to the queue of messages to be sent. In response to the judgment signal, the sequenced messages in the queue of messages to be sent can be sorted.
[0054] Sorting the sequence messages in the queue of messages to be sent according to the order of consumption means changing the output order of the sequence messages in the queue of messages to be sent. The sequence messages in the queue of messages to be sent will be output to the server in the order of consumption, and the sequence messages output to the server first will be consumed and processed by the message consumers first. Therefore, by sorting the sequence messages in the queue of messages to be sent according to the rule that the sequence messages processed first will be output first, these sequence messages can be sorted in the order of consumption.
[0055] In step S150, the message partition refers to a storage partition in the server for storing sequential messages, for example, a partition in the server is a message partition. The target message partition is a message partition selected from multiple message partitions in the server to store sequential messages in the sorted queue.
[0056] Sending the sequential messages in the sorted queue to the target message partition in the order of consumption means that when accessing the server at one time, the sequential messages in the sorted queue are sent to the target message partition in the order of consumption. In this way, when accessing the server at one time, either all of these sequential messages are sent successfully or all of them fail to be sent. In this way, on the one hand, the order of the sequential messages in the same batch can be ensured when all the sequential messages are sent successfully; on the other hand, it can be ensured that when the sequential messages fail to be sent, the sequential messages in the batch are not stored in the target message partition, avoiding the situation where some messages are successfully sent to the target message partition and causing the messages in the same batch to be incomplete, thereby ensuring the integrity of the sequential messages in the same batch.
[0057] In summary, the above steps S110 to S160 of the message sending method M100 can ensure the sequence and integrity of sequential messages in the same consumption batch without the need for the message producer to increase its workload to customize the messages to be sent in the order of consumption, so that the sequential messages in the same consumption batch can be consumed and processed by the message consumers in the predetermined consumption order.
[0058] In some implementations, in step S110, obtaining the message to be sent specifically includes: detecting whether the initial message generated by the message producer is sent from the message producer, and intercepting the initial message when the initial message is sent to obtain the message to be sent.
[0059] The initial message refers to a message produced by the message producer and needs to be sent to the server. When the initial message is ready to be sent, it is sent from the message producer with the server as the sending address. Once the initial message is sent, before the initial message is sent to the server, the data containing the initial message is intercepted to prevent it from being sent to the server. At this time, the intercepted initial message is the message to be sent.
[0060] That is to say, the message producer does not need to set the sending time and sending order of the initial message. The initial message will be intercepted as a message to be sent, and the sending time and sending order of the sequential messages in the message to be sent are determined according to the message sending method M100 provided by the present disclosure. In this way, the business workload of the message producer can be reduced and the work efficiency of the message producer can be improved.
[0061] See also Figure 3 In some implementations, in step S120, identifying whether the message to be sent is a sequential message includes steps S121 to S123.
[0062] S121: Obtain preset message topics, each preset message topic includes sequential messages of the same consumption batch and respective consumption orders of the sequential messages of the same consumption batch.
[0063] The message subject refers to the specific business category corresponding to the message. The preset message subject refers to the specific business of a specific category that is pre-configured. For example, the preset message subject may include commodity trading business, financial lending business, financial management business, personnel management business, etc., which are not listed here one by one. Business items with specific processing procedures can be configured with corresponding preset message subjects.
[0064] Taking commodity trading business as an example, the processing flow of commodity trading business includes multiple process nodes. When the message subject of the sequence message is commodity trading business, the sequence message is a message corresponding to one of the multiple process nodes of commodity trading business, and the order of the sequence message is the order of the corresponding process node in all process nodes of commodity trading business. For example, if the sequence message is an order payment message, then the sequence message corresponds to the order payment node in the commodity trading business, and the order of the sequence message is the order of the order payment node in all process nodes.
[0065] That is to say, the sequential messages included in each preset message topic correspond to multiple process nodes of the message topic, and each complete process (from the first process node to the last process node) is a batch. The consumption order of each sequential message in the same consumption batch is the order of its corresponding process node in the process.
[0066] S122: Obtain the message subject of the message to be sent, and determine whether the message subject of the message to be sent is a preset message subject.
[0067] In one example, the message to be sent has a corresponding topic identifier, and the topic identifier is used to identify the corresponding message topic. For example, a specific string can be used as the topic identifier, and a corresponding identifier dictionary can be configured. When the topic identifier of the message to be sent is obtained, the corresponding message topic can be identified through the identifier dictionary. If the message topic is within the set of preset message topics, the message topic is a preset message topic.
[0068] S123: In response to a determination signal that the message subject of the to-be-sent message is a preset message subject, identifying the to-be-sent message as a sequential message in the corresponding preset message subject.
[0069] That is, after judging whether the message subject of the message to be sent is the preset message subject, two judgment signals may be generated, representing two judgment results, namely, the judgment results representing whether the message subject of the message to be sent is the preset subject message or not. If the generated judgment signal represents that the message subject of the message to be sent is the preset message subject, then a recognition result is obtained in response to the judgment signal, and the recognition result is that the message to be sent is a sequential message in the corresponding preset message subject.
[0070] Through the above steps S12 to S123, on the one hand, it is possible to identify whether the message to be sent is a sequential message, and on the other hand, it is possible to simultaneously identify the preset message subject corresponding to the sequential message, so that in subsequent steps, the sequential message can be cached to the message queue to be sent corresponding to the message subject based on the preset message subject.
[0071] See also Figure 4 In some further implementations, in step S120, identifying whether the message to be sent is a sequential message includes steps S124 to S125.
[0072] S124: Perform semantic recognition on the message to be sent to determine whether the message to be sent is a flow-previous message or a flow-post message.
[0073] S125: In response to a determination signal that the message to be sent is a flow-previous message or a flow-next message, the message to be sent is identified as a sequence message.
[0074] Semantic recognition can be achieved through a natural language processing model. For example, a natural language processing model is trained using a known information dataset of process context messages and process context messages, so that the trained natural language processing model can output a judgment result based on the input message text. The judgment result can indicate whether the input message text is a process context message or a process context message, so as to perform semantic recognition using the trained natural language processing model.
[0075] A process context message means that the subsequent process corresponding to the message is incomplete and should have a subsequent process. For example, the message to be sent is an order generation message. In commodity trading business, the order generation process does not exist independently. There are subsequent processes after the order is generated. In this case, the order generation message is a process context message.
[0076] A process-below message means that the previous process to which the message corresponds is incomplete and there should be a previous process. For example, the message to be sent is an order closing message. In commodity trading business, the order closing process does not exist independently, and its predecessor should at least have an order generation process. In this case, the order closing message is a process-below message.
[0077] The same message to be sent may be a flow preceding message, or a flow following message, or both a flow preceding message and a flow following message, or neither a flow preceding message nor a flow following message.
[0078] For example, a certain order payment message should have at least an order generation message as its predecessor and at least an order completion message as its successor. Then the order payment message is both a process context message and a process context message.
[0079] For example, a notification message, the content of which is not associated with the content of other notification messages, and the content of which does not require a reply. That is, the business process corresponding to the notification message starts when the notification message is sent, and ends after the notification message is sent, with no preceding or subsequent processes. Therefore, the notification message is neither a process preceding message nor a process following message.
[0080] The judgment signal of whether the message to be sent is a flow upper message or a flow lower message includes three judgment signals. The first judgment signal indicates that the message to be sent is a flow upper message; the second judgment signal indicates that the message to be sent is a flow lower message; the third judgment signal indicates that the message to be sent is both a flow upper message and a flow lower message. When responding to any of the above three judgment signals, the message to be sent is identified as a sequential message.
[0081] If the judgment signal indicates that the message to be sent is neither a process preceding message nor a process following message, the message to be sent is not a sequential message and can be sent to the server without subsequent processing steps.
[0082] See also Figure 5 In some implementations, in step S130, the identified sequential messages are added to a queue of messages to be sent, including steps S131 to S134.
[0083] S131: Obtain the message subject of the sequence message.
[0084] S132: Determine whether there is a created queue of messages to be sent that corresponds to the message topic of the sequence message.
[0085] S133: In response to a determination signal that there is a created queue of to-be-sent messages corresponding to the message subject of the sequence message, the sequence message is added to the queue of to-be-sent messages corresponding to the message subject of the sequence message.
[0086] S134: In response to a judgment signal that there is no created queue of messages to be sent corresponding to the message subject of the sequential message, a new queue of messages to be sent is created, and the sequential message is added to the new queue of messages to be sent, wherein the new queue of messages to be sent corresponds to the message subject of the sequential message.
[0087] The created message queue to be sent is a message queue with a storage address. Each created message queue to be sent uniquely corresponds to a message topic.
[0088] If the message subject of the acquired sequential message corresponds to the created queue of messages to be sent, a corresponding determination signal is generated, and in response to the determination signal, the sequential message is added to the queue of messages to be sent corresponding to the same message subject.
[0089] If the message subject of the acquired sequential message does not correspond to any created queue of messages to be sent, a corresponding judgment signal is generated, and a new queue of messages to be sent is created in response to the judgment signal, and the sequential message is added to the new queue of messages to be sent.
[0090] For example, the created send message queues include queue 1 and queue 2. The message topic corresponding to queue 1 is the first topic, and the message topic corresponding to queue 2 is the second topic. Assuming that the message topic of the acquired sequential message A is the first topic, there is a queue 1 corresponding to the first topic, and the sequential message A is added to queue 1. Assuming that the message topic of the acquired sequential message B is the third topic, there is no created message queue corresponding to the third topic, so it is necessary to create a queue 3, and add the sequential message B to queue 3, and queue 3 corresponds to the third topic.
[0091] See also Figure 6 In some implementations, in step S130, determining whether sequential messages of the same consumption batch are all added to the queue of messages to be sent includes: step S135, step S136 to step S137.
[0092] S135: In response to the signal that the sequence message is added to the queue of messages to be sent, the batch identifier and the sequence identifier of the sequence message are obtained, wherein the batch identifier representing the same consumption batch corresponds to multiple sequence identifiers.
[0093] S136: Determine whether all the multiple sequence identifiers corresponding to the batch identifier are acquired.
[0094] S137: In response to a judgment signal indicating that all the multiple sequence identifiers corresponding to the batch identifier have been obtained, a judgment result is obtained that all the sequence messages of the same consumption batch are added to the queue of messages to be sent.
[0095] The batch identifier represents the message batch corresponding to the sequential message (i.e., the message consumption batch, referred to as the message batch, the same below). In one example, the sequential messages corresponding to the various process nodes in the same process from start to finish correspond to the same message batch and have the same batch identifier. For example, in the commodity trading business topic, a certain commodity has orders from two different buyers. Although the transaction process content of the two buyers to purchase the commodity is the same, they belong to two different batches of transaction processes. For example, the order payment message in the transaction process of buyer A and the order payment message in the transaction process of buyer B belong to different batches of sequential messages.
[0096] The sequence identifier represents the order of the sequence message among the sequence messages in the corresponding message batch. In other words, the same message batch corresponds to one batch identifier and multiple sequence identifiers, that is, the identifier representing the same consumption batch corresponds to multiple sequence identifiers.
[0097] When the batch identifier of a sequence message is obtained, the message batch corresponding to the sequence message can be determined. Once the message batch corresponding to the sequence message is determined, the sequence messages included in the message batch and the sequence identifiers of these sequence messages can be obtained. If the sequence identifiers of the sequence messages included in the same message batch have been obtained, the sequence messages representing the message batch are added to the queue of messages to be sent.
[0098] For example, a message batch P1 includes 3 sequential messages, and the corresponding sequence identifiers are identifier 1, identifier 2, and identifier 3, respectively. The sequence of identifier 1 precedes identifier 2, and the sequence of identifier 2 precedes identifier 3. Assuming that the sequence identifier that has been obtained is identifier 1, when sequential message B is added to the queue of messages to be sent, in response to the signal that sequential message B has been added, the batch identifier and sequence identifier of sequential message B are obtained, and batch P1 and identifier 2 are obtained. At this time, in the sequence identifiers corresponding to message batch P1, identifier 3 has not been obtained, and the judgment result of step S136 is "not all obtained". Assuming that sequential message C is subsequently added to the queue of messages to be sent, in response to the signal that sequential message C has been added, the batch identifier and sequence identifier of sequential message C are obtained, and batch P1 and identifier 3 are obtained. At this time, the sequence identifiers corresponding to message batch P1 have all been obtained, and the judgment result of step S137 is "not all obtained", then in response to the judgment signal of step S137, the judgment result that the sequential messages of the same consumption batch are all added to the queue of messages to be sent is obtained.
[0099] In an example, based on the sequence identifiers of the sequence messages having been obtained, in step S140, the sequence messages in the to-be-sent message queue are sorted according to the order of consumption to obtain a sorted queue, specifically including: based on the consumption order represented by the sequence identifiers of the sequence messages in the to-be-sent message queue, each sequence message is sorted in the order of corresponding consumption from first to last to obtain a sorted queue.
[0100] For example, the queue of messages to be sent includes three sequential messages: sequential message A, sequential message C, and sequential message B. The sequence identifiers of these three sequential messages are represented by numbers. The larger the number, the later the consumption order. If the sequence identifier of sequential message A is "1", the sequence identifier of sequential message C is "3", and the sequence identifier of sequential message B is "2", then in the obtained sorted queue, the three sequential messages are sequential message A, sequential message B, and sequential message C in order of consumption from first to last.
[0101] See also Figure 7 In step S150, the sequential messages in the sorted queue are continuously sent to the target message partition in the order of consumption, including: steps S151 to S154.
[0102] S151: Obtain the number of multiple partitions to be selected.
[0103] S152: Obtain the number of sent sorted queues.
[0104] S153: Perform a modulo calculation on the number of partitions to be selected based on the number of sent sorted queues to obtain an i-th modulo value.
[0105] S154: Select a target message partition from multiple candidate partitions based on the i-th remainder value, and continuously send the sequential messages in the i-th sorted queue to the target message partition in the order of consumption.
[0106] Where i=j+1, j is the number of sorted queues that have been sent.
[0107] The candidate partition is a storage partition in the server that can be selected as a target partition. In one example, the count value j represents the number of sent sorted queues. After each sorted queue is sent, the count value j increases by 1.
[0108] Assuming that the number of multiple partitions to be selected is n, and the i-th remainder value is m, then 0≤m≤n-1, that is, m is an integer in the range of [0, n-1]. The number of integers in the range of [0, n-1] is n, and when performing the remainder calculation, the remainder value m increases one by one as the number of sent sorted queues j increases, and the value of m changes one by one in the range of [0, n-1]. When j grows infinitely, m traverses the integers in the range of [0, n-1] one by one. Based on this, if each partition to be selected is corresponded one by one to the integers in the range of [0, n-1], and the target message partition is selected from multiple partitions to be selected based on the i-th remainder value m, it can be ensured that each partition to be selected is evenly selected. In this way, it can be guaranteed that the sequential messages are evenly distributed to each partition to be selected, so that when the consumer of the message obtains messages from multiple partitions to be selected in parallel, the message processing efficiency of the consumer of the message can be improved.
[0109] In one example, step S144 specifically includes: when the i-th remainder value is equal to m, selecting the m+1th candidate partition as the target message partition.
[0110] For example, the number of partitions to be selected is 2, and when the number of sent sorted queues j=5, the target message partition is selected for the next (i.e., the sixth) sorted queue. Then, when j=5 and n=2, the remainder value calculated by taking j modulo n is 1, i.e., the sixth remainder value m6=1, so the second partition to be selected is selected as the target message partition among the two partitions to be selected.
[0111] Assume that the number of sent sorted queues j=6, and select the target message partition for the next (i.e., the 7th) sorted queue. Then, when j=6 and n=2, the remainder value calculated by taking j modulo n is 0, i.e., the 7th remainder value m7=0, so the first candidate partition is selected as the target message partition among the two candidate partitions.
[0112] Based on any of the above implementations, the present disclosure further provides an electronic device 1000, which can execute the message sending method of any implementation described above in the present disclosure.
[0113] Figure 8 1 is a schematic block diagram of the structure of an electronic device 1000 according to an embodiment of the present disclosure.
[0114] The hardware structure of the electronic device 1000 can be implemented using a bus architecture. The bus architecture can include any number of interconnected buses and bridges, depending on the specific application and overall design constraints of the hardware. The bus 1100 connects various circuits including one or more processors 1200, memory 1300 and / or hardware modules together. The bus 1100 can also connect various other circuits 1400 such as peripherals, voltage regulators, power management circuits, external antennas, etc.
[0115] The bus 1100 may be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Component (EISA) bus, etc. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, the figure only uses one connecting line, but does not mean that there is only one bus or one type of bus.
[0116] The electronic device 1000 further includes: The acquisition module 1002 is used to acquire the message to be sent.
[0117] The identification module 1004 is used to identify whether the message to be sent is a sequence message. The sequence messages of the same consumption batch have a preset consumption order.
[0118] The judgment module 1006 is used to add the identified sequence messages to the queue of messages to be sent, and to judge whether all the sequence messages of the same consumption batch are added to the queue of messages to be sent.
[0119] The sorting module 1008 is used to respond to the judgment signal that the sequence messages of the same consumption batch are all added to the queue of messages to be sent, sort the sequence messages in the queue of messages to be sent according to the consumption order, and obtain a sorted queue.
[0120] The sending module 1010 is used to continuously send the sequential messages in the sorted queue to the target message partition in the order of consumption.
[0121] The embodiments of the present disclosure also provide a computer-readable storage medium, in which execution instructions are stored, and when the execution instructions are executed by a processor, they are used to implement the above-mentioned method. "Readable storage medium" can be any device that can contain, store, communicate, propagate or transmit programs for use in an instruction execution system, device or equipment or in combination with these instruction execution systems, devices or equipment. More specific examples of readable storage media include the following: an electrical connection portion with one or more wirings (electronic device), a portable computer disk box (magnetic device), a random access memory (RAM), a read-only memory (ROM), an erasable and editable read-only memory (EPROM or flash memory), an optical fiber device, and a portable read-only memory (CDROM), etc.
[0122] The embodiments of the present disclosure also provide a computer program product, including a computer program / instruction, which implements the question answering method provided in the embodiments of the present disclosure when the computer program / instruction processor is executed.
[0123] The method in the embodiment of the present disclosure can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer programs or instructions. When the computer program or instruction is loaded and executed on a computer, the process or function of the present application is executed in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, a network device, a user device, a core network device, an OAM or other programmable device.
[0124] A computer program or instruction may be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another computer-readable storage medium, for example, a computer program or instruction may be transmitted from one website, computer, server or data center to another website, computer, server or data center by wired or wireless means. A computer-readable storage medium may be any available medium that a computer can access or a data storage device such as a server or data center that integrates one or more available media. Available media may be magnetic media, such as a floppy disk, hard disk, or magnetic tape; may also be optical media, such as a digital video disk; or may be semiconductor media, such as a solid-state drive. The computer-readable storage medium may be a volatile or non-volatile storage medium, or may include both volatile and non-volatile types of storage media.
[0125] Those skilled in the art will appreciate that the embodiments of the present disclosure may be provided as methods, systems, or computer program products. Therefore, the present disclosure may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present disclosure may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0126] In the description of this specification, the description with reference to the terms "one embodiment / method", "some embodiments / methods", "example", "specific example", or "some examples" etc. means that the specific features, structures, materials or characteristics described in conjunction with the embodiment / method or example are included in at least one embodiment / method or example of the present application. In this specification, the schematic representations of the above terms are not necessarily the same embodiment / method or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or more embodiments / methods or examples in a suitable manner. In addition, those skilled in the art may combine and combine the different embodiments / methods or examples described in this specification and the features of the different embodiments / methods or examples, unless they are contradictory.
[0127] In addition, the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Therefore, the features defined as "first" and "second" may explicitly or implicitly include at least one of the features. In the description of this application, the meaning of "plurality" is at least two, such as two, three, etc., unless otherwise clearly and specifically defined.
[0128] Those skilled in the art should understand that the above embodiments are only for the purpose of clearly illustrating the present disclosure and the technical solutions of the present disclosure, rather than limiting them. The protection scope of the present disclosure is not limited thereto. Although the present disclosure is described in detail with reference to the above embodiments, those skilled in the art should understand that any person skilled in the art who is familiar with the present technical field can still modify the technical solutions recorded in the above embodiments within the technical scope disclosed in the present disclosure or can easily think of changes, or make equivalent replacements for some of the technical features therein; and these modifications, changes or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present disclosure, and should be included in the protection scope of the present disclosure. Therefore, the protection scope of the present disclosure shall be based on the protection scope of the claims.
Claims
1. A message sending method, characterized in that: include: Get the message to be sent; Identify whether the message to be sent is a sequential message, wherein the sequential messages of the same consumption batch have a preset consumption order; Add the identified sequential messages to the queue of messages to be sent, and determine whether all the sequential messages of the same consumption batch are added to the queue of messages to be sent; In response to a determination signal that the sequenced messages of the same consumption batch are all added to the queue of messages to be sent, sorting the sequenced messages in the queue of messages to be sent according to a consumption order to obtain a sorted queue; and The sequential messages in the sorted queue are continuously sent to the target message partition in the order of consumption.
2. The message sending method according to claim 1, characterized in that: Get the message to be sent, including: It is detected whether the initial message generated by the producer of the message is sent from the producer of the message, and the initial message is intercepted when the initial message is sent to obtain the message to be sent.
3. The message sending method according to claim 1, characterized in that: Identifying whether the message to be sent is a sequential message includes: Obtaining a preset message topic, each of the preset message topics includes a plurality of sequential messages of the same consumption batch and respective consumption orders of the plurality of sequential messages of the same consumption batch; Obtaining the message subject of the message to be sent, and determining whether the message subject of the message to be sent is the preset message subject; and In response to a determination signal that the message subject of the to-be-sent message is the preset message subject, the to-be-sent message is identified as the sequential message in the corresponding preset message subject.
4. The message sending method according to claim 1, characterized in that: Identifying whether the message to be sent is a sequential message includes: Performing semantic recognition on the message to be sent to determine whether the message to be sent is a flow preceding message or a flow following message; and In response to a determination signal that the message to be sent is a flow-previous message or a flow-next message, the message to be sent is identified as the sequence message.
5. The message sending method according to claim 1, characterized in that: Adding the identified sequential messages to a queue of messages to be sent includes: Obtain the message subject of the sequential message; Determine whether there is a created queue of messages to be sent corresponding to the message subject of the sequential message; In response to a determination signal that there is a created queue of messages to be sent corresponding to the message subject of the sequential message, adding the sequential message to the queue of messages to be sent corresponding to the message subject of the sequential message; and In response to a judgment signal that there is no created queue of messages to be sent corresponding to the message subject of the sequential message, a new queue of messages to be sent is created, and the sequential message is added to the new queue of messages to be sent, wherein the new queue of messages to be sent corresponds to the message subject of the sequential message of the sequential message.
6. The message sending method according to claim 1, characterized in that: Determining whether the sequenced messages of the same consumption batch are all added to the queue of messages to be sent includes: In response to a signal that the sequence message is added to the queue of messages to be sent, a batch identifier and a sequence identifier of the sequence message are obtained, wherein the batch identifier representing the same consumption batch corresponds to a plurality of sequence identifiers; Determining whether all of the plurality of sequence identifiers corresponding to the batch identifier are acquired; and In response to a judgment signal indicating that all the multiple sequence identifiers corresponding to the batch identifier have been obtained, a judgment result is obtained that all the sequence messages of the same consumption batch are added to the queue of messages to be sent.
7. The message sending method according to claim 1, characterized in that: Continuously sending the sequenced messages in the sorted queue to the target message partition in the order of consumption, including: Get the number of multiple partitions to be selected; Obtaining the number of the sorted queues that have been sent; Performing a modulo calculation on the number of the partitions to be selected based on the number of the sent sorted queues to obtain an i-th modulo value; and Select the target message partition from the multiple partitions to be selected based on the i-th remainder value, and continuously send the sequence messages in the i-th sorted queue to the target message partition in the order of consumption; Wherein, i=j+1, j is the number of the sorted queues that have been sent.
8. An electronic device, characterized in that: include: A memory storing execution instructions; as well as A processor, wherein the processor executes the execution instruction stored in the memory, so that the processor executes the message sending method according to any one of claims 1 to 7.
9. A readable storage medium, characterized in that: The readable storage medium stores a computer program, and when the computer program is executed by a processor, it is used to implement the message sending method according to any one of claims 1 to 7.
10. A computer program product, characterized in that The computer program product comprises a computer program, and when the computer program is executed by a processor, the computer program is at least used to implement the message sending method according to any one of claims 1 to 7.
