Message processing method and device based on synchronization code block, equipment and storage medium

By splitting the target message into multiple fragments and using synchronized code blocks to control their serial processing, the problems of low execution efficiency and high deadlock probability of fragmented messages in the bank's message sending and receiving system are solved, achieving more efficient code execution and reducing deadlock.

CN116633872BActive Publication Date: 2026-01-23BANK OF CHINA
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202310400222.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-04-13
Publication Date
2026-01-23
Estimated Expiration
2043-04-13

AI Technical Summary

Technical Problem

Existing bank message sending and receiving systems suffer from low efficiency and a high probability of deadlock when processing business detail verification response messages that exceed the preset length.

Method used

The target message is split into multiple fragmented messages that are executed one by one in execution order. The parsing of each fragmented message and the data writing to the database table are executed one by one through synchronous code blocks. The database table is updated only after all fragmented messages have been executed. Synchronous locks are allocated through synchronous code blocks to control the serial execution of fragmented messages.

Benefits of technology

It reduces operational and code redundancy, lowers the probability of deadlock, achieves logical separation between business control and business implementation, and improves code execution efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116633872B_ABST
    Figure CN116633872B_ABST
Patent Text Reader

Abstract

The application provides a message processing method and device based on a synchronous code block, equipment and a storage medium, which can be used in the financial field or other fields. The method comprises the following steps: receiving a target message; in the case that the length of the target message is greater than a preset length, all target messages are split into multiple fragmented messages which are executed one by one based on an execution sequence; the multiple fragmented messages are parsed, the fragmented messages are executed one by one based on the execution sequence according to the synchronous code block, and the data corresponding to the fragmented messages is written into a database table; after the execution of all fragmented messages corresponding to the target message is completed, the database table is updated. Through the method of the application, the technical effect of improving the message execution efficiency and reducing the probability of deadlock can be achieved.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the field of finance, and in particular to a message processing method and device based on synchronized code blocks, equipment and a storage medium. BACKGROUND

[0002] With the rapid development of the Internet, message fragmentation technology has become a commonly used technical means for transmitting messages. In a data communication network, messages need to be sent out through the physical layer, and the length of the data frame that can be sent each time is limited by the physical layer. When the size of the message sent by the sending end exceeds the maximum length that the physical layer can bear, the message to be sent is processed by fragmentation based on message fragmentation technology, and the multiple fragmented messages after fragmentation are sent to the receiving end in series. The processing capacity of fragmented messages has become an important indicator for measuring the performance of network equipment. The receiving process includes parsing messages, writing into database tables, and updating database tables.

[0003] In the existing bank message receiving and sending system, when there are a large number of business detail check response messages whose lengths often exceed the preset length 1M of the bank message receiving and sending system, the business detail check response messages need to be split into multiple fragmented messages. The receiving method is modified based on synchronized, and the complete parsing of messages, writing into database tables, and updating database table operations are serially executed for each fragmented message. Finally, whether the message processing has been completed is determined by comparing the total number of fragmented messages that have been processed in the Detail Transaction Report (DTR) with the total number of records of fragmented messages.

[0004] Since the receiving method is modified based on synchronized, the complete parsing of messages, writing into database tables, and updating database table operations are serially executed for each fragmented message. The updating database table operations before the execution of the last fragmented message end are redundant operations, and the corresponding code also has serious redundancy. Moreover, since there are multiple fragmented message writing into database table operations, a deadlock is easily caused when the synchronized lock is not released in time. The message processing method in the prior art has the technical problems of low execution efficiency of fragmented messages and high probability of deadlock. SUMMARY

[0005] The present application provides a message processing method and device based on synchronized code blocks, equipment and a storage medium to solve the technical problems of low execution efficiency of fragmented messages and high probability of deadlock.

[0006] In a first aspect, the present application provides a message processing method based on synchronized code blocks, comprising:

[0007] receiving a target message, and splitting the target message into multiple fragmented messages that are executed one by one based on execution order in the case that the length of the target message is greater than a preset length.

[0008] The plurality of fragmented messages are parsed, and the fragmented messages are executed one by one based on the execution order according to the synchronization code block, and the data corresponding to the fragmented messages is written into the database table;

[0009] After the execution of all the fragmented messages corresponding to the target message is completed, the database table is updated.

[0010] Optionally, the fragmented messages are executed one by one based on the execution order according to the synchronization code block, and the data corresponding to the fragmented messages is written into the database table, comprising:

[0011] The synchronization code block allocates a synchronization lock to the next fragmented message to be executed one by one according to the execution order;

[0012] After the fragmented message obtains the synchronization lock and waits for a preset time length, the synchronization lock is released, the fragmented message is executed, and the data corresponding to the fragmented message is written into the database table.

[0013] Optionally, the target message is split into a plurality of fragmented messages which are executed one by one based on the execution order, comprising:

[0014] The first number of fragmented messages obtained by splitting the target message is obtained.

[0015] Optionally, after the data corresponding to the fragmented message is written into the database table, comprising:

[0016] The second number of fragmented messages for which the corresponding data has been written into the database table is obtained;

[0017] When the second number is less than the first number, the synchronization code block allocates a synchronization lock to the next fragmented message to be executed one by one according to the execution order.

[0018] Optionally, after the second number of fragmented messages for which the corresponding data has been written into the database table is obtained, comprising:

[0019] When the first number is equal to the second number, it is determined that the execution of all the fragmented messages corresponding to the target message is completed.

[0020] Optionally, after the fragmented message obtains the synchronization lock and waits for a preset time length, the synchronization lock is released, comprising:

[0021] The synchronization code block determines the next fragmented message to be executed according to the execution order;

[0022] The synchronization code block allocates a synchronization lock to the next fragmented message to be executed.

[0023] Optionally, after the synchronization code block allocates a synchronization lock to the next fragmented message to be executed one by one according to the execution order, comprising:

[0024] determine the shard message that does not obtain the synchronization lock as a waiting execution state based on the plurality of shard messages corresponding to the target message and the next shard message to be executed.

[0025] determine the shard message that does not obtain the synchronization lock as a waiting execution state based on the plurality of shard messages corresponding to the target message and the next shard message to be executed.

[0026] In a second aspect, the present application provides a message processing device based on a synchronization code block, comprising:

[0027] a first processing module, configured to receive a target message, and split the target message into a plurality of shard messages based on an execution order in a case that a length of the target message is greater than a preset length;

[0028] a second processing module, configured to parse the plurality of shard messages, execute the shard messages based on a synchronization code block according to the execution order, and write data corresponding to the shard messages into a database table;

[0029] an updating module, configured to update the database table after execution of all the shard messages corresponding to the target message is completed.

[0030] Optionally, the second processing module is configured to:

[0031] the synchronization code block allocates a synchronization lock to the next shard message to be executed according to the execution order;

[0032] in a case that the shard message obtains the synchronization lock and waits for a preset time length, release the synchronization lock, execute the shard message, and write data corresponding to the shard message into the database table.

[0033] Optionally, the first processing module is configured to:

[0034] obtain a first number of the shard messages split from the target message.

[0035] Optionally, the device is further configured to:

[0036] obtain a second number of the shard messages for which the corresponding data has been written into the database table;

[0037] in a case that the second number is less than the first number, the synchronization code block allocates a synchronization lock to the next shard message to be executed according to the execution order.

[0038] Optionally, the device is further configured to:

[0039] in a case that the first number is equal to the second number, determine that execution of all the shard messages corresponding to the target message is completed.

[0040] Optionally, the device is further configured to:

[0041] the synchronization code block determines the next shard message to be executed according to the execution order;

[0042] The synchronization code block allocates the synchronization lock to the next to-be-executed fragmented message.

[0043] Optionally, the apparatus is further configured to:

[0044] Based on the plurality of fragmented messages corresponding to the target message and the next to-be-executed fragmented message, determine the fragmented message that does not obtain the synchronization lock;

[0045] Determine the fragmented message that does not obtain the synchronization lock as a waiting execution state.

[0046] In a third aspect, the present application provides a message processing device based on a synchronization code block, comprising a processor and a memory in communication connection with the processor;

[0047] The memory stores computer execution instructions;

[0048] The processor executes the computer execution instructions stored in the memory to implement the message processing method based on the synchronization code block of the first aspect.

[0049] In a fourth aspect, the present application provides a computer readable storage medium, the computer readable storage medium stores computer execution instructions, and the computer execution instructions are executed by the processor to implement the message processing method based on the synchronization code block of the first aspect.

[0050] In a fifth aspect, the present application provides a program product, the program product comprises a computer program, and the computer program is executed by the processor to implement the message processing method based on the synchronization code block of the first aspect.

[0051] The message processing method and device based on the synchronization code block, the equipment and the storage medium provided by the present application, in the case that the length of the received target message is greater than the preset length, the target message is split into a plurality of fragmented messages based on the execution order and executed one by one, the plurality of fragmented messages are parsed, the serial processing of the fragmented messages is realized based on the synchronization code block, the data corresponding to the fragmented messages is written into the database table, and the database table is updated after all the fragmented messages are executed. The synchronization lock is allocated by the synchronization code block to control the fragmented messages to be executed in series according to the execution order and written into the database table. The message parsing and the database table updating operation are not controlled synchronously. The database table is updated only after all the fragmented messages are executed. The operation and code redundancy are reduced, and the probability of deadlock is reduced. The synchronization code block does not involve the business logic of the received message. The logical separation of business control and business implementation is realized. The resource consumption is reduced on the premise of ensuring the smooth progress of the business. The technical effects of improving the code execution efficiency and reducing the probability of deadlock are realized. BRIEF DESCRIPTION OF DRAWINGS

[0052] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application.

[0053] Figure 1 The message processing method based on synchronization code blocks provided in the embodiments of this application Figure One ;

[0054] Figure 2 The message processing method based on synchronization code blocks provided in the embodiments of this application Figure Two ;

[0055] Figure 3 The message processing method based on synchronization code blocks provided in the embodiments of this application Figure Three ;

[0056] Figure 4 The message processing method based on synchronization code blocks provided in the embodiments of this application Figure Four ;

[0057] Figure 5 A schematic diagram of the structure of a message processing device based on a synchronization code block provided in an embodiment of this application;

[0058] Figure 6 This is a schematic diagram of the structure of a message processing device based on a synchronization code block, provided in an embodiment of this application.

[0059] The accompanying drawings illustrate specific embodiments of this application, which will be described in more detail below. These drawings and descriptions are not intended to limit the scope of the concept in any way, but rather to illustrate the concept of this application to those skilled in the art through reference to particular embodiments. Detailed Implementation

[0060] Exemplary embodiments will now be described in detail, examples of which are illustrated in the accompanying drawings. When the following description relates to the drawings, unless otherwise indicated, the same numbers in different drawings denote the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this application. Rather, they are merely examples of apparatuses and methods consistent with some aspects of this application as detailed in the appended claims.

[0061] Existing message receiving systems use synchronized locks to modify the message receiving method when processing received fragmented messages. All operations are executed serially, requiring the parsing, writing to the database table, and updating the database table to be performed multiple times. This results in severe code redundancy and low execution efficiency. If synchronized locks are only used on the code that writes to the database table, the parsing and updating operations do not need to participate in synchronization. However, the operation of writing to the database table is a database input / output I / O operation. If the locks are not released in time, there is a risk of deadlock.

[0062] The message processing method, apparatus, device, and storage medium based on synchronous code blocks provided in this application, when the length of the received target message exceeds a preset length, splits the target message into multiple fragmented messages that are executed sequentially according to the execution order. These fragmented messages are then parsed, and synchronous code blocks are used to implement serial processing of the fragmented messages. The data corresponding to each fragmented message is written to a database table, and the database table is updated after all fragmented messages have been executed. By allocating synchronous locks through synchronous code blocks, the serial execution of fragmented messages and their writing to the database table are controlled according to the execution order. Message parsing and database table updates are not synchronously controlled; the database table is updated only after all fragmented messages have been executed, reducing operational and code redundancy and lowering the probability of deadlock. The synchronous code blocks do not involve the business logic of receiving messages, achieving a separation of business control and business implementation logic. This reduces resource consumption while ensuring smooth business operation, achieving the technical effects of improving code execution efficiency and reducing the probability of deadlock.

[0063] The technical solution of this application and how it solves the above-mentioned technical problems will be described in detail below with specific embodiments. These specific embodiments can be combined with each other, and the same or similar concepts or processes may not be described again in some embodiments. The embodiments of this application will be described below with reference to the accompanying drawings.

[0064] Figure 1 The message processing method based on synchronization code blocks provided in the embodiments of this application Figure One .like Figure 1 As shown, the message processing method based on synchronization code blocks provided in this embodiment includes:

[0065] S101. Receive the target message. If the length of the target message is greater than the preset length, split the target message into multiple fragmented messages that are executed one by one according to the execution order.

[0066] In this embodiment, the target message can be received serially or in parallel. Serial reception refers to receiving fragmented messages one by one, while parallel reception refers to receiving all fragmented messages simultaneously. If the length of the target message is greater than a preset length, the target message is split into multiple fragmented messages, and multiple fragmented messages are received serially to ensure the correctness of the business logic. After all fragmented messages have been received, fragmented message parsing is started. In a specific example, the target message is a business detail verification response message (ibps.704.001.01). If the length of the business detail verification response message is greater than the preset length of 1M, the business detail verification response message is split into multiple fragmented messages that are executed sequentially based on the execution order. After receiving all fragmented messages serially, business detail reconciliation processing is performed sequentially based on the execution order of the multiple fragmented messages.

[0067] S102. Parse multiple fragmented packets, execute the fragmented packets one by one according to the execution order based on the synchronous code block, and write the data corresponding to the fragmented packets into the database table.

[0068] In this embodiment, a synchronized code block refers to a Java code block modified by a synchronized lock. The essence of a synchronized code block is a multi-threaded protection mechanism, which allows only one thread to enter the synchronized code block at any given time.

[0069] S103. After all fragmented packets corresponding to the target packet have been executed, update the database table.

[0070] In this embodiment, when receiving a target message, the data of the target message is written to a database table by executing the fragmented messages corresponding to the target message. The number of fragmented messages that have been written to the database table is obtained by querying the database table to determine whether all fragmented messages corresponding to the target message have been executed. When the number of fragmented messages that have been written to the database table is equal to the number of fragmented messages corresponding to the target message, the database table is updated to determine that all fragmented messages corresponding to the target message have been executed, and the status of the target message is determined to be acknowledged.

[0071] In this embodiment, a synchronization lock is allocated for writing to the database table based on the synchronization code block. The operations of parsing messages and updating the data table are not controlled by the synchronization lock. The database table is updated after all fragmented messages have been processed. The logic of this message receiving process conforms to the basic principle of multi-threaded parallel processing. In parallel coding, the content of the synchronization code block can be minimized and simplified as much as possible, avoiding the invocation of another synchronization lock within a synchronization lock, and also avoiding database I / O operations within the synchronization lock.

[0072] The message processing method based on synchronous code blocks provided in this application, when the length of the received target message exceeds a preset length, splits the target message into multiple fragmented messages that are executed sequentially according to the execution order. These fragmented messages are parsed, and serial processing of the fragmented messages is implemented using synchronous code blocks. The data corresponding to each fragmented message is written to a database table, and the database table is updated after all fragmented messages have been executed. By allocating synchronous locks through synchronous code blocks, the serial execution of fragmented messages and their writing to the database table are controlled according to the execution order. Message parsing and database table updates are not controlled synchronously; the database table is only updated after all fragmented messages have been executed. This reduces operational and code redundancy and lowers the probability of deadlock. The synchronous code blocks do not involve the business logic of receiving messages, achieving a separation of business control and business implementation logic. This reduces resource consumption while ensuring smooth business operation, achieving the technical effects of improving code execution efficiency and reducing the probability of deadlock.

[0073] Figure 2 The message processing method based on synchronization code blocks provided in the embodiments of this application Figure Two This embodiment provides a message processing method based on synchronization code blocks, including:

[0074] S201. Receive the target message. If the length of the target message is greater than the preset length, obtain the first number of fragments into which the target message is split.

[0075] S202. Parse multiple fragmented packets, and the synchronization code block allocates synchronization locks to the next fragmented packet to be executed one by one according to the execution order.

[0076] S203. Based on the multiple fragmented messages corresponding to the target message and the next fragmented message to be executed, determine the fragmented messages that have not acquired the synchronization lock; and determine the fragmented messages that have not acquired the synchronization lock as waiting to be executed.

[0077] S204. After acquiring the synchronization lock in a fragmented packet and waiting for a preset time, the synchronization lock is released. The synchronization code block determines the next fragmented packet to be executed according to the execution order. The synchronization code block allocates the synchronization lock to the next fragmented packet to be executed.

[0078] In this embodiment, the system waits for a preset time by executing critical section code, and does not perform input / output I / O techniques within the critical section code block.

[0079] S205. Execute the fragmented message and write the data corresponding to the fragmented message into the database table; obtain the second number of fragmented messages whose data has been written into the database table.

[0080] S206. When the first number equals the second number, determine that all fragmented messages corresponding to the target message have been executed; when the second number is less than the first number, the synchronization code block allocates synchronization locks to the next fragmented message to be executed one by one according to the execution order.

[0081] S207. After all fragmented packets corresponding to the target packet have been executed, update the database table.

[0082] Through the above steps S201 to S207, synchronization locks are allocated one by one based on the execution order of the fragmented packets. This controls the writing of fragmented packets to the database table according to the execution order, while asynchronously controlling packet parsing and database table updates. The database table is updated only after all fragmented packets have been executed, reducing operation and code redundancy. After a fragmented packet acquires a synchronization lock, it waits for a preset time before releasing the lock and then executing the fragmented packet to write to the database table. This achieves the separation of synchronization content from packet reception code, improving code execution efficiency and reducing the probability of deadlock.

[0083] In the first example, Figure 3 The flowchart of the message processing method based on synchronization code blocks provided in the embodiments of this application Figure Three The target message includes fragment A and fragment B, and the execution order is fragment A, fragment B, such as... Figure 3 As shown, the message processing method based on synchronization blocks includes:

[0084] S301. The transceiver system receives fragmented message A and fragmented message B, and allocates a synchronization lock to fragmented message A based on the synchronization code block.

[0085] S302. After fragment A acquires the synchronization lock, wait for a preset time by executing critical section code, release the synchronization lock, execute the thread corresponding to fragment A, and write the data corresponding to fragment A into the database table by executing the receiving method.

[0086] S303. When fragmented message B does not acquire the synchronization lock, it is in a waiting execution state, that is, the thread corresponding to fragmented message B is in a blocked state. After fragmented message A releases the synchronization lock, fragmented message B acquires the synchronization lock, waits for a preset time by executing critical section code, releases the synchronization lock, executes fragmented message B, and writes the data corresponding to fragmented message B into the database table by executing the receiving method.

[0087] S304. After fragmented message A and fragmented message B have been executed, the execution of the target message ends, and the database table is updated.

[0088] In the first example above, the preset duration can be 1 second or 2 seconds. The above preset duration is only used to illustrate the process of receiving fragmented messages. The preset duration can be adjusted through specific tests. This application does not limit the preset duration.

[0089] In the second example, the target message includes fragment A and fragment B, and the execution order is fragment C, fragment D, and fragment E, with a preset duration of 1 second. Figure 4 The flowchart of the message processing method based on synchronization code blocks provided in the embodiments of this application Figure Four ,like Figure 4 As shown, the message processing method based on synchronization blocks includes:

[0090] S401, The transceiver system receives fragmented message C, fragmented message D, and fragmented message E;

[0091] S402. Based on the synchronization code block, allocate a synchronization lock to fragmented message C. After fragmented message C acquires the synchronization lock, wait for 1 second by executing critical section code, release the synchronization lock, and execute the thread corresponding to fragmented message C; write the data corresponding to fragmented message C into the database table by executing the receiving method.

[0092] S403. Fragmented messages D and E are in a waiting execution state when they do not acquire a synchronization lock, that is, the threads corresponding to fragmented messages D and E are in a blocked state.

[0093] S404. After fragmented message C releases the synchronization lock, fragmented message D acquires the synchronization lock. After waiting for 1 second by executing critical section code, the synchronization lock is released, fragmented message D is executed, and the data corresponding to fragmented message D is written to the database table by executing the receiving method.

[0094] S405. After fragmented message D releases the synchronization lock, fragmented message E acquires the synchronization lock. After waiting for 1 second by executing critical section code, the synchronization lock is released, fragmented message E is executed, and the data corresponding to fragmented message E is written to the database table by executing the receiving method.

[0095] S406. After fragmented message C, fragmented message D, and fragmented message E have all been executed, the execution of the target message ends, the database table is updated, and the status of the target message is determined to be acknowledged.

[0096] The message processing method based on synchronous code blocks provided in this application, when the length of the received target message exceeds a preset length, splits the target message into multiple fragmented messages that are executed sequentially according to the execution order. The method parses these fragmented messages, serially processes them using synchronous code blocks, and writes the corresponding data of each fragmented message into a database table. After all fragmented messages have been executed, the database table is updated. The method controls the serial execution of fragmented messages and their writing to the database table by allocating synchronous locks through synchronous code blocks, without synchronously controlling message parsing and database table updates. The database table is only updated after all fragmented messages have been executed, reducing operations and code redundancy. The synchronous code blocks do not involve the business logic of receiving messages. After a fragmented message acquires a synchronous lock, it waits a preset time before releasing the lock and then executing the message writing operation to the database table. This achieves separation of synchronous content from message reception code, i.e., separation of business control and business implementation logic. This reduces resource consumption while ensuring smooth business operations, achieving the technical effects of improving code execution efficiency and reducing the probability of deadlock.

[0097] Figure 5 This is a schematic diagram of the structure of a message processing device based on synchronization code blocks provided in an embodiment of this application. Figure 5 As shown in the figure, an embodiment of this application provides a message processing device 500 based on a synchronization code block, including: a first processing module 501, a second processing module 502, and an update module 503.

[0098] The first processing module 501 is used to receive the target message and, if the length of the target message is greater than the preset length, split the target message into multiple fragmented messages that are executed one by one according to the execution order.

[0099] The second processing module 502 is used to parse multiple fragmented packets, execute the fragmented packets one by one according to the execution order based on the synchronous code block, and write the data corresponding to the fragmented packets into the database table.

[0100] The update module 503 is used to update the database table after all fragmented packets corresponding to the target packet have been executed.

[0101] The message processing device based on synchronous code blocks provided in this application includes a first processing module, a second processing module, and an update module. When the length of the received target message is greater than a preset length, the first processing module splits the target message into multiple fragmented messages that are executed sequentially. Then, the second processing module parses the multiple fragmented messages, uses synchronous code blocks to implement serial processing of the fragmented messages, and writes the data corresponding to the fragmented messages into a database table. After all fragmented messages have been executed, the update module updates the database table. The synchronous code blocks release the message parsing, writing to the database table, and updating of the database table from synchronization. The synchronous code blocks do not involve the business logic of receiving messages, and the business control and business implementation logic are completely separated. While ensuring smooth business operation, resource consumption is reduced, and the technical effects of improving code execution efficiency and preventing deadlock are achieved.

[0102] In one possible implementation, the second processing module is used for:

[0103] Synchronous code blocks allocate synchronization locks to the next fragment to be executed one by one according to the execution order;

[0104] After acquiring a synchronization lock for a fragmented message and waiting for a preset time, the synchronization lock is released, the fragmented message is executed, and the data corresponding to the fragmented message is written to the database table.

[0105] In one possible implementation, the first processing module is used for:

[0106] Get the first number of fragments into which the target message is split.

[0107] In one possible implementation, the device is also used for:

[0108] Get the second number of fragmented packets whose corresponding data has been written to the database table;

[0109] When the second number is less than the first number, the synchronization code block allocates synchronization locks to the next fragment to be executed one by one according to the execution order.

[0110] In one possible implementation, the device is also used for:

[0111] When the first number equals the second number, it is determined that all fragmented packets corresponding to the target packet have been executed.

[0112] In one possible implementation, the device is also used for:

[0113] The synchronous code block determines the next fragment to be executed based on the execution order;

[0114] The synchronized block allocates the synchronization lock to the next fragment to be executed.

[0115] In one possible implementation, the device is also used for:

[0116] Based on the multiple fragmented messages corresponding to the target message and the next fragmented message to be executed, identify the fragmented messages that have not acquired the synchronization lock;

[0117] Fragmented messages that have not acquired a synchronization lock are identified as waiting to be executed.

[0118] The message processing device based on synchronous code blocks provided in this application includes a first processing module, a second processing module, and an update module. When the length of the received target message is greater than a preset length, the first processing module splits the target message into multiple fragmented messages that are executed sequentially. Then, the second processing module parses the multiple fragmented messages, uses synchronous code blocks to implement serial processing of the fragmented messages, and writes the data corresponding to the fragmented messages into a database table. After all fragmented messages have been executed, the update module updates the database table. The synchronous code blocks release the message parsing, writing to the database table, and updating of the database table from synchronization. The synchronous code blocks do not involve the business logic of receiving messages, and the business control and business implementation logic are completely separated. While ensuring smooth business operation, resource consumption is reduced, and the technical effects of improving code execution efficiency and preventing deadlock are achieved.

[0119] Figure 6 A schematic diagram of a message processing device based on synchronization code blocks provided in this application embodiment, the device comprising:

[0120] Processor 601 and memory 602;

[0121] The memory stores the instructions that the computer executes;

[0122] The processor executes computer execution instructions stored in memory 602, causing the message processing device based on synchronization code blocks to perform the message processing method based on synchronization code blocks as described above.

[0123] It should be understood that the processor 601 described above can be a Central Processing Unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), etc. The general-purpose processor can be a microprocessor or any conventional processor. The steps of the method disclosed in this invention can be directly implemented by a hardware processor, or implemented by a combination of hardware and software modules within the processor. The memory 602 may include high-speed random access memory (RAM), and may also include non-volatile memory (NVM), such as at least one disk storage device, and may also be a USB flash drive, external hard drive, read-only memory, disk, or optical disc, etc.

[0124] This application also provides a computer-readable storage medium storing computer-executable instructions, which, when executed by a processor, are used to implement the message processing method based on synchronization code blocks as described above.

[0125] This disclosure provides a computer program product, including a computer program that, when executed by a processor, implements the message processing method based on synchronization code blocks as described above.

[0126] Other embodiments of this application will readily occur to those skilled in the art upon consideration of the specification and practice of the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of this application that follow the general principles of this application and include common knowledge or customary techniques in the art not disclosed herein. The specification and examples are to be considered exemplary only, and the true scope and spirit of this application are indicated by the following claims.

[0127] It should be understood that this application is not limited to the precise structure described above and shown in the accompanying drawings, and various modifications and changes can be made without departing from its scope. The scope of this application is limited only by the appended claims.

Claims

1. A message processing method based on synchronization code blocks, characterized in that, include: Upon receiving a target message, if the length of the target message is greater than a preset length, the target message is split into multiple fragmented messages that are executed one by one in execution order. The multiple fragmented packets are parsed, and based on the synchronization code block, synchronization locks are allocated to the next fragmented packet to be executed one by one according to the execution order; After the segmented message acquires the synchronization lock and waits for a preset time, the synchronization lock is released, the segmented message is executed, and the data corresponding to the segmented message is written into the database table. After all the fragmented packets corresponding to the target packet have been executed, the database table is updated.

2. The method according to claim 1, characterized in that, The step of splitting the target message into multiple fragmented messages executed sequentially based on the execution order includes: Obtain the first number of fragments into which the target message is split.

3. The method according to claim 2, characterized in that, After writing the data corresponding to the fragmented packet into the database table, the process includes: Obtain the second number of the fragmented packets whose corresponding data has been written into the database table; When the second number is less than the first number, the synchronization code block allocates the synchronization lock to the next fragment message to be executed one by one according to the execution order.

4. The method according to claim 3, characterized in that, After obtaining the second number of fragmented packets whose corresponding data has been written to the database table, the process includes: When the first number equals the second number, it is determined that all fragmented packets corresponding to the target packet have been executed.

5. The method according to claim 1, characterized in that, After acquiring the synchronization lock in the fragmented message and waiting for a preset time, and then releasing the synchronization lock, the process includes: The synchronous code block determines the next fragment to be executed according to the execution order; The synchronization block allocates the synchronization lock to the next fragment message to be executed.

6. The method according to claim 1, characterized in that, After the synchronization code block allocates synchronization locks to the next fragment of the message to be executed one by one according to the execution order, the following is included: Based on the multiple fragmented messages corresponding to the target message and the next fragmented message to be executed, the fragmented messages that have not acquired the synchronization lock are determined; The fragmented message that has not acquired the synchronization lock is identified as waiting to be executed.

7. A message processing apparatus based on a synchronization code block, characterized in that, include: The first processing module is used to receive the target message and, if the length of the target message is greater than a preset length, split the target message into multiple fragmented messages that are executed one by one according to the execution order. The second processing module is used to parse the multiple fragmented packets and, based on the synchronization code block, allocate synchronization locks to the next fragmented packet to be executed one by one according to the execution order. After the segmented message acquires the synchronization lock and waits for a preset time, the synchronization lock is released, the segmented message is executed, and the data corresponding to the segmented message is written into the database table. The update module is used to update the database table after all the fragmented packets corresponding to the target packet have been executed.

8. A message processing device based on synchronization code blocks, characterized in that, include: A processor, and a memory communicatively connected to the processor; The memory stores computer-executed instructions; The processor executes computer execution instructions stored in the memory to implement the message processing method based on synchronization code blocks as described in any one of claims 1 to 6.

9. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer-executable instructions, which, when executed by a processor, are used to implement the message processing method based on synchronization code blocks as described in any one of claims 1 to 6.

Citation Information

Patent Citations

  • Data processing method and device, electronic equipment and storage medium

    CN114201297A

  • Message processing method and device, electronic equipment and storage medium

    CN115514774A