Message queue load processing method and system applied to multi-service scenario

CN122653864APending Publication Date: 2026-08-28ZUNYI BIG DATA GROUP CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202610818189.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-06-08
Publication Date
2026-08-28

AI Technical Summary

Technical Problem

在分布式部署和高并发场景下,多个业务消费者实例并发处理同一业务实例的消息时,各自独立的去重逻辑难以保证全局一致的状态判断顺序,容易出现重复消费引发的业务状态错乱问题

Benefits of technology

[0006] This invention constructs a projection state machine instance, corresponding one-to-one with each business instance, at the message queue broker layer to record the current projection state of the business instance in the entire lifecycle state chain. The broker layer reads the business unique key and the target state transition identifier from the message header of the received message to be delivered. Based on the business unique key, it queries and matches the corresponding target projection state machine instance and extracts the current projection state. The target state transition identifier is compared with the current projection state input state transition rule set to determine whether it conforms to a valid transition path. If it conforms, the message is sent and the projection state is updated; otherwise, delivery is blocked. This method moves the message deduplication and idempotency guarantee mechanism from the business consumer end to the message queue broker layer. It performs business semantic awareness filtering only based on the business unique key and the target state transition identifier in the message header, transforming the message queue from a stateless transmission pipeline into a proactive process adjudication facility. It can complete the business semantic level message legality and duplication determination without parsing the message payload, avoiding the state chaos and resource waste caused by duplicate messages to downstream business consumers, and significantly reducing the development complexity and operating overhead of business consumers. Meanwhile, the projection state machine instance is bound to the business unique key for storage and the transition path is compared and blocked according to the set of state transition rules. This ensures that the operation of multiple consumer instances on the same business instance in a distributed environment strictly follows the predetermined state evolution order, eliminates the state rollback and illegal transition problems caused by concurrent delivery, and improves the consistency of message delivery and the reliability of the delivery business process in multi-business scenarios.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122653864A_ABST
    Figure CN122653864A_ABST
Patent Text Reader

Abstract

The application provides a message queue load processing method and system applied to a multi-service scenario. A projection state machine instance corresponding to a service instance is constructed at a message queue agent layer to record a current projection state; a business unique key and a target state transition identifier are parsed from a message header when a message is received; the target projection state machine instance is obtained by querying and matching according to the business unique key, and the current projection state is extracted; the target state transition identifier and the current projection state are input into a preset state transition rule set, and it is judged whether the expected transition at this time belongs to a legal transition path; when it is judged to be legal, the message is delivered to a consumer instance and the projection state is updated, and when it is judged to be illegal, the delivery is blocked and discarding or audit dumping is performed. The application enables the message middleware to have a verification capability of understanding business state flow semantics, intercepts illegal state transition messages at the agent layer, and guarantees the state consistency among the instances of the distributed distribution business.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of data processing, and in particular to a message queue load processing method and system applicable to multi-service scenarios. Background Technology

[0002] In various business scenarios such as food delivery, messages related to order creation, status changes, and payment callbacks all need to be transmitted to downstream business consumers via message queues for processing. In existing technologies, message queues typically act as stateless transmission pipelines, only responsible for temporary message storage and delivery. Message deduplication and idempotency guarantees are entirely left to the business consumers to implement upon receiving the message. Business consumers need to maintain processing records or use locking mechanisms locally to identify and discard duplicate messages or reject messages with illegal status transitions. In distributed deployments and high-concurrency scenarios, when multiple business consumer instances concurrently process messages from the same business instance, their independent deduplication logic cannot guarantee a globally consistent order of status checks, easily leading to business status confusion caused by duplicate consumption. Furthermore, distributing status verification logic across different business consumers increases development complexity and operational overhead, and the varying degrees of idempotency guarantees implemented by different business consumers make it difficult to form a unified and reliable message delivery protection capability. Summary of the Invention

[0003] This invention provides a message queue load processing method and system applicable to multiple service scenarios.

[0004] In a first aspect, embodiments of the present invention provide a message queue load balancing method applicable to multi-service scenarios, including: In the message queue broker layer, a projection state machine instance is constructed that corresponds one-to-one with the business instance. The projection state machine instance records the current projection state of the corresponding business instance in the delivery business process. The current projection state is an abstract state node in the full lifecycle state chain from the creation of the delivery order to the completion of the delivery. The message queue broker layer receives messages to be delivered from the message producer and reads the business unique key and the target state transition identifier from the message header of the message to be delivered. The business unique key is used to uniquely identify the business instance to which the message to be delivered belongs, and the target state transition identifier is used to indicate the next abstract state node of the business instance that the message to be delivered is expected to drive. Based on the read business unique key, a query and match is performed in the set of projection state machine instances maintained by the message queue broker layer to obtain the target projection state machine instance associated with the business unique key, and the current projection state of the business instance is extracted from the target projection state machine instance. The target state transition identifier is compared with the extracted current projected state input to the preset state transition rule set to determine whether the transition from the current projected state to the abstract state node pointed to by the target state transition identifier conforms to the legal transition path defined in the preset state transition rule set. When the comparison result is consistent, the message queue broker layer sends the message to be delivered to the consumer instance and updates the current projection state of the target projection state machine instance to the abstract state node pointed to by the target state transition identifier. When the comparison result is inconsistent, the message queue broker layer blocks the delivery operation of the message to be delivered and discards or dumps the message to be delivered to the audit queue.

[0005] Secondly, embodiments of the present invention provide a computer system including a memory and a processor, wherein the memory stores a computer program that can run on the processor, and the processor executes the program to implement the steps in the above-described method.

[0006] This invention constructs a projection state machine instance, corresponding one-to-one with each business instance, at the message queue broker layer to record the current projection state of the business instance in the entire lifecycle state chain. The broker layer reads the business unique key and the target state transition identifier from the message header of the received message to be delivered. Based on the business unique key, it queries and matches the corresponding target projection state machine instance and extracts the current projection state. The target state transition identifier is compared with the current projection state input state transition rule set to determine whether it conforms to a valid transition path. If it conforms, the message is sent and the projection state is updated; otherwise, delivery is blocked. This method moves the message deduplication and idempotency guarantee mechanism from the business consumer end to the message queue broker layer. It performs business semantic awareness filtering only based on the business unique key and the target state transition identifier in the message header, transforming the message queue from a stateless transmission pipeline into a proactive process adjudication facility. It can complete the business semantic level message legality and duplication determination without parsing the message payload, avoiding the state chaos and resource waste caused by duplicate messages to downstream business consumers, and significantly reducing the development complexity and operating overhead of business consumers. Meanwhile, the projection state machine instance is bound to the business unique key for storage and the transition path is compared and blocked according to the set of state transition rules. This ensures that the operation of multiple consumer instances on the same business instance in a distributed environment strictly follows the predetermined state evolution order, eliminates the state rollback and illegal transition problems caused by concurrent delivery, and improves the consistency of message delivery and the reliability of the delivery business process in multi-business scenarios. Attached Figure Description

[0007] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present invention and, together with the specification, serve to explain the technical solutions of the present invention.

[0008] Figure 1This is a logical diagram illustrating a message queue load processing method applied to multi-service scenarios, provided by an embodiment of the present invention.

[0009] Figure 2 This is a schematic diagram illustrating the implementation process of a message queue load processing method applied to multi-service scenarios, provided by an embodiment of the present invention.

[0010] Figure 3 This is a schematic diagram of the hardware entity of a computer system provided in an embodiment of the present invention. Detailed Implementation

[0011] To make the objectives, technical solutions, and advantages of the present invention clearer, the technical solutions of the present invention will be further described in detail below with reference to the accompanying drawings and embodiments. The described embodiments should not be regarded as limitations on the present invention. All other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0012] This invention provides a message queue load balancing method applicable to multi-service scenarios, which can be executed by a computer system's processor. The computer system can refer to devices with data processing capabilities, such as servers, laptops, tablets, and desktop computers.

[0013] Please combine Figure 1 and Figure 2 Referring to the present invention, an embodiment of a message queue load balancing method for multi-service scenarios includes the following steps: Step S100: Construct a projection state machine instance that corresponds one-to-one with the business instance in the message queue broker layer. The projection state machine instance records the current projection state of the corresponding business instance in the delivery business process. The current projection state is an abstract state node in the full lifecycle state chain from the creation of the delivery order to the completion of the delivery.

[0014] The message queue proxy layer is a proxy process running in the message queue service cluster. This process not only undertakes the functions of receiving, storing, routing and delivering messages, but also embeds the state machine projection capability defined in this solution, enabling the middleware, which was originally only responsible for data forwarding, to understand the semantics of the upper-layer business flow.

[0015] A business instance refers to the logical entity corresponding to each independent delivery order in a real delivery scenario. This entity is created from the moment the user submits the order and completes the payment, and it goes through the entire lifecycle from merchant confirmation, rider acceptance, in-store pickup, delivery in progress, to final successful delivery or abnormal closure. Each business instance has a globally unique business identifier for differentiation and tracking in the distributed system.

[0016] The projection state machine instance is a lightweight data structure maintained by the message queue broker layer in its own process's heap memory space. Unlike the complete business order records stored in the remote business system database, this data structure only projects the most critical state information of the business instance during the flow. Its purpose is to enable the message queue broker layer to complete the business validity verification at the moment the message flows through without having to look back at the business database.

[0017] There is a strict one-to-one correspondence between the projection state machine instance and the business instance. When the message queue broker layer receives the first message belonging to a certain business instance, it will initialize a dedicated projection state machine instance and continuously maintain the synchronous evolution of its state during the life cycle of the business instance. Once the business instance transitions to the final state, the corresponding projection state machine instance will be cleaned up by a lazy recycling strategy after a preset survival time.

[0018] The current projection state is a snapshot of the projection state machine instance at a certain moment, pointing to a specific abstract state node in the full lifecycle state chain. This snapshot value does not contain the local operation details of the business instance within this stage. For example, the continuous location trajectory information reported by the rider after arriving near the merchant will not be reflected in the current projection state. Only when the rider completes the food pickup operation and triggers the state to jump upward will the current projection state be updated to the next abstract state node.

[0019] The full lifecycle state chain is a directed state link formed through abstract modeling in the delivery business domain. This link enumerates all the key stages that a delivery order must go through from creation to completion. Each stage is condensed into an abstract state node. These nodes are connected to each other by legal transition paths, forming a directed acyclic graph or a strictly partial-order state transition topology. Typical nodes may include order initialization, pending merchant confirmation, merchant accepted order, goods shipped, rider accepted order, rider arrived at store, rider picked up goods, delivery in transit, station delivered, user signed for delivery, and abnormal cancellation, etc.

[0020] Abstract state nodes represent a semantic enhancement of the actual operational steps in the delivery business. They use an immutable and unique state name identifier to represent the business fact reached by the business instance at the end of the step. For example, when a merchant completes the preparation and delivery operation and delivers the goods to the rider, the business instance completes the state transition from "the merchant has accepted the order" to "the rider has picked up the goods". After this point in time, the current projected state recorded by the message queue broker layer is overwritten with the state name identifier corresponding to "the rider has picked up the goods".

[0021] In practice, when the message queue broker layer starts, it requests a large-granularity reserved memory area from the operating system's memory manager as an allocation pool for the projection state machine instance. Each free unit in this allocation pool is initialized with a sequence of all zero bytes. When a new projection state machine instance needs to be constructed, the memory allocator retrieves a free unit from the free list of the allocation pool and forcibly types-casts the starting address of the free unit to a pointer to the projection state machine instance structure. This structure, in its memory layout, sequentially contains a fixed-length business unique key storage area, a current projection state storage area, a last state transition timestamp record area, a reference count area, and a pointer area pointing to additional extended data. After completing the allocation of memory units and zero-value initialization, the message queue broker layer copies the business unique key field carried by the first message byte by byte to the business unique key storage area, and writes a string termination marker at the end of the area. At the same time, it copies the name identifier of the default starting abstract state node to the current projected state storage area. This default starting abstract state node usually corresponds to the initial state of order initialization. Finally, it writes the current system timestamp to the last state transition timestamp record area and sets the reference count to the active state. At this point, a projected state machine instance bound to the business instance and having completed the initial state injection is constructed and enters the ready state.

[0022] Step S200: The message queue broker layer receives the message to be delivered sent by the message producer, and reads the business unique key and the target state transition identifier from the message header of the message to be delivered. The business unique key is used to uniquely identify the business instance to which the message to be delivered belongs, and the target state transition identifier is used to indicate the next abstract state node of the business instance that the message to be delivered is expected to drive.

[0023] In one embodiment, step S200 may specifically include the following steps S210 to S260: Step S210: Allocate a circular buffer for the message producer connection in the memory pool of the message queue broker layer, and set the memory pages of the circular buffer to non-swapable attribute. When the byte stream sent by the message producer arrives at the network card, the network card writes the byte stream into the free area pointed to by the tail pointer of the circular buffer through memory access operation, and obtains the original byte sequence of the message to be delivered.

[0024] The memory pool is a large contiguous virtual address space that the message queue broker layer requests from the operating system in advance during the startup phase. This space is divided into multiple fixed-size physical memory pages and classified and managed according to different uses. The area dedicated to network input / output buffering is further divided into multiple circular buffers of the same size for exclusive use by each incoming message producer connection.

[0025] A circular buffer is a logically contiguous block of bytes that appears as a linear address space in physical memory. However, access control employs a cyclical approach using head and tail pointers for writing and reading. When the tail pointer reaches the physical end, it automatically wraps back to the starting address, allowing for continuous reception of network data streams without frequent memory allocation and deallocation. The non-swapability of memory pages means that the message queue broker layer, by calling the operating system's application programming interface, locks the physical memory pages containing the circular buffer in physical random access memory, preventing the operating system's page swapping mechanism from moving these pages to disk swap space. This ensures that latency on the network data write path in high-throughput scenarios does not experience unpredictable jitter due to page faults and disk I / O. When a message producer sends a message to be delivered via a Transmission Control Protocol (TCP) connection, the message is encapsulated into a complete message frame at the byte stream level. The byte stream first arrives at the network interface card (NIC) receive queue of the server where the message queue broker layer is located. The direct memory access engine on the NIC, based on the descriptor table pre-registered on the ring buffer, bypasses the central processing unit and directly writes the payload byte stream of the received Ethernet frame after unpacking into the free memory area pointed to by the tail pointer of the ring buffer in the form of a bus transaction. The starting position of the write is determined by the current value of the tail pointer. After the write is completed, the NIC updates the tail pointer to the new position and sends a hard interrupt signal to the central processing unit to notify that new data has arrived. Thus, the original byte sequence of one or more messages to be delivered is continuously deposited in the ring buffer, waiting for the subsequent frame parsing and message extraction steps.

[0026] Step S220: Starting from the head pointer position of the circular buffer, scan the original byte sequence, detect the occurrence position of the message frame separator in the original byte sequence, determine the start offset address and end offset address of the message to be delivered, and extract a complete message frame byte sequence from the circular buffer according to the start offset address and end offset address.

[0027] The header pointer is a variable in the circular buffer control structure. It always points to the address of the earliest byte in the circular buffer that has not yet been consumed by the message parsing logic. Each time a complete message frame is processed, the header pointer moves forward by the corresponding number of bytes to release the consumed buffer space. The message frame delimiter is a fixed sequence of magic number bytes agreed upon by the message queue broker layer and the message producer in the binary frame protocol. This sequence is placed at the beginning and end of each complete message frame, or only at the beginning of the frame, recording the total frame length. This constitutes a synchronization marker used to define frame boundaries. The specific byte pattern of the frame delimiter uses specially designed four-byte or eight-byte constants that have an extremely low probability of appearing in the business message payload, to minimize frame boundary misjudgments caused by the payload content being exactly the same as the delimiter.

[0028] For example, after the message processing thread is awakened, it starts from the address indicated by the head pointer of the circular buffer and scans the original byte sequence byte by byte. During the scanning process, it maintains a fast pattern matching state machine based on a partial matching table. Each time the state machine reads a byte, it looks up the table based on the previous state and the value of the current byte and jumps to the next state. Once the state machine recognizes a continuous byte subsequence that is completely consistent with the predetermined message frame delimiter, it records the address of the first byte of the subsequence as a candidate frame start offset address. Then it continues to scan backward to find the position of the next message frame delimiter and records its first byte address as the frame end offset address, or calculates the frame end offset address based on the frame length field at a fixed offset after the frame start offset address. Once the start and end offset addresses are determined, the message processing thread calculates the range of consecutive bytes occupied by the frame in the circular buffer. If the range does not cross the end boundary of the physical memory of the circular buffer, all bytes are copied directly from the start offset address to form a copy of the complete message frame byte sequence. If the range is divided into two physically discontinuous segments due to the circular wrapping, the byte segment from the start offset address to the physical end of the buffer is first copied to the lower address of the temporary assembly area, and then the byte segment from the physical start address to the end offset address is copied to the higher address immediately following the temporary assembly area, thus assembling a logically continuous complete message frame byte sequence for subsequent steps to perform structured parsing.

[0029] Step S230: Parse the fixed-length preamble of the complete message frame byte sequence, read the total length field, protocol version field and message header length field in sequence, calculate the offset range of the message header part in the complete message frame byte sequence through the value of the message header length field, and map the consecutive bytes within the offset range to the message header field set.

[0030] The fixed-length preamble is the first few bytes of a complete message frame's byte sequence. Its length is fixed as a small integer constant during the message frame protocol design phase. This area stores key control information such as the total length field, protocol version field, and message header length field in a compact binary format. All message producers and message queue brokers conforming to this protocol version encode and decode this area according to a unified byte order and field width convention. The total length field occupies the first few bytes of the fixed-length preamble and records the total number of bytes in the entire message frame from the start-of-frame delimiter to the end-of-frame delimiter as an unsigned integer. This field not only provides auxiliary verification when segmenting message frames from the byte stream but also provides an accurate memory page mapping range for subsequent zero-copy transmission.

[0031] The protocol version field is a short integer field following the total length field. Its value indicates the binary frame protocol version number followed by the message frame during encoding. Different protocol versions may differ in the field layout of the message header, the encoding method of custom attribute sections, and the existence of optional extended fields. The introduction of the protocol version field ensures that the message queue broker layer can upgrade the protocol in a backward compatible manner without affecting online services. The message header length field records the total number of bytes occupied by the message header portion starting from the end of the fixed-length preamble. The message header portion itself is a variable-length structure, and its actual length is dynamically determined by the message producer based on the number of key-value pairs and the length of the value byte string. The existence of the message header length field allows the parsing logic to accurately locate the boundary between the message header and the message payload without prior knowledge of the internal structure of the message header.

[0032] Specifically, the message processing logic first casts the starting address of the complete message frame byte sequence to a pointer to a fixed-length preamble structure. Then, it reads the binary representations of the total length field, protocol version field, and message header length field sequentially according to the field offset order of this structure, performing necessary byte order conversions based on the local byte order to obtain three integer values. Next, using the fixed length value of the fixed-length preamble as the base offset, and with this base offset as the starting position and the integer value of the message header length field as the interval length, a left-closed, right-open offset range is defined within the complete message frame byte sequence. All bytes within this offset range constitute the continuous byte sequence of the message header. The message header field set is an in-memory associative data structure, typically implemented using a hash map or a balanced search tree. The message processing logic passes the byte sequence of the message header to a protocol version-aware message header parser. This parser first reads the total number of key-value pairs and the compact encoding of each key-value pair in the message header, then restores the key name string and value byte string for each pair, and inserts each key-value pair into the message header field set. This ultimately forms a complete message metadata mapping table indexed by key name, which subsequent steps can use to extract the business unique key and target state transition identifier as needed.

[0033] Step S240: In the message header field set, find the corresponding message header layout template using the protocol version field as the index, determine the base address offset and segment length of the custom attribute segment in the message header field set according to the message header layout template, and cut out the custom attribute segment byte sequence that matches the base address offset and segment length from the message header field set.

[0034] The message header layout template is a set of metadata description structures pre-built into the message queue broker layer. Each template is bound to a specific protocol version number. The template records in detail the binary arrangement details of the message header under that protocol version, including the offset and bit width of each built-in field, the position of the existence flag of optional extended fields, and the calculation rules for the starting offset of custom attribute sections in the entire message header and the maximum allowed length. Since different protocol versions may adjust the structure of the message header, using a message header layout template that strictly corresponds to the field values ​​of the protocol version can ensure that the parsing logic always extracts custom attribute sections with the correct offset, avoiding field misalignment due to protocol mismatch.

[0035] The custom attribute section is a contiguous byte region within the message header that immediately follows all built-in fields. This region uses type-length value encoding or its variants to store any key-value pairs that the message producer wants to transmit with the message. For example, a business-specific key and a target state transition identifier can both exist as two sets of key-value pairs within the custom attribute section. The boundaries of the custom attribute section are jointly determined by the base offset and the section length. The base offset is defined in the message header layout template as a positive integer offset relative to the start address of the message header. It points to the position of the first byte of the custom attribute section within the message header. The section length is usually calculated by subtracting the base offset from the total length of the message header, or it can be explicitly given by a dedicated length field in the custom attribute section header.

[0036] Specifically, the message processing logic first uses the integer value of the protocol version field parsed in step S230 as the key to perform a constant-time lookup in the global registry of the message header layout template, obtaining a pointer to the corresponding message header layout template structure. This structure contains a custom attribute segment base address offset field and a custom attribute segment length calculation rule identifier. The message processing logic then reads the starting address of the memory area occupied by the message header field set, adds the value of the base address offset field to the starting address to obtain the absolute starting address of the custom attribute segment in memory. At the same time, it obtains the segment length value according to the method indicated by the custom attribute segment length calculation rule identifier. If the rule identifier indicates implicit calculation mode, the total message header length minus the base address offset is used as the segment length. If the rule identifier indicates explicit prefix mode, an unsigned short integer is read from the first two bytes at the starting address as the segment length. After obtaining the absolute starting address and segment length, the message processing logic cuts out a continuous byte copy defined by the absolute starting address and segment length from the underlying byte storage of the message header field set. This copy is the byte sequence of the custom attribute segment. All subsequent key-value pair decoding work will be carried out around this copy, rather than directly manipulating the original memory of the message header field set, so as to avoid the pointer offset during the decoding process from causing side effects on subsequent access to the message header.

[0037] Step S250: Perform key-value pair decoding on the byte sequence of the custom attribute segment, parse out multiple sets of key-value pairs pre-filled by the message producer, and temporarily store the parsed sets of key-value pairs in a temporary key-value pair set. Each set of key-value pairs in the temporary key-value pair set consists of a key name string and a value area byte string.

[0038] In one embodiment, step S250 may specifically include the following steps S251 to S256: Step S251: Read the integer value of the total number of key-value pairs from the first two bytes of the byte sequence of the custom attribute segment, and initialize an offset index array with the corresponding number of elements according to the total number of key-value pairs. The value of the first element of the offset index array points to the byte position immediately following the total number of key-value pairs.

[0039] The first two bytes of the custom attribute segment byte sequence are defined by the protocol as an unsigned short integer counter for the total number of key-value pairs. Regardless of how many key-value pairs the message producer fills in, the total number of pairs in network byte order must be written at this position. When decoding, the message queue broker layer first reads these two bytes and converts them to an integer value in host byte order. The offset index array is a fixed-length integer array allocated on the stack, with the number of elements equal to the integer value of the total number of key-value pairs. This array is used to sequentially record the starting offset address of each key-value pair in the custom attribute segment byte sequence. The value of its first element is initialized to the position immediately following the two bytes of the total number of key-value pairs, which is an offset of constant 2. Starting from this position, the key name length identifier of the first key-value pair and subsequent bytes are stored.

[0040] Step S252: Starting from the starting offset of each key-value pair recorded in the offset index array, read a one-byte key name length identifier from the starting offset of the current key-value pair, use the integer value represented by the key name length identifier as the key name byte length, and offset the read pointer to the starting address of the key name byte string.

[0041] In one embodiment, step S252 may specifically include the following steps S2521 to S2526: Step S2521: Before accessing the starting offset of the current group key-value pair recorded in the offset index array, the current byte order mode of the central processing unit executing the method is detected. When the current byte order mode is little endian, all multi-byte values ​​read from the byte sequence of the custom attribute segment are byte-reversed and uniformly converted to big endian representation.

[0042] The byte order mode of the central processing unit refers to the arrangement order of bytes when the processor stores multi-byte data. In little-endian mode, the least significant byte is stored at the lowest address, and in big-endian mode, the most significant byte is stored at the lowest address. Big-endian, or network byte order, is commonly used in network transmission. Before decoding each key-value pair, this step obtains the current byte order mode by reading the processor status register or calling a built-in function. If little-endian is detected, each multi-byte field read from the custom attribute segment byte sequence undergoes a byte reversal macro operation before participating in arithmetic or comparison operations. This macro operation converts the multi-byte value from a big-endian storage representation to a host-side numerical representation by swapping the first and last bytes, allowing all subsequent integer value interpretation logic to be executed based on consistent numerical semantics, without having to handle byte order issues separately at each read point.

[0043] Step S2522: Using the starting offset as the base address, read a byte from the base address, map the eight-bit binary value of the byte to an unsigned integer, assign the unsigned integer to the key name length identifier variable, and do not perform sign bit extension processing on the eight-bit binary value.

[0044] After determining the byte order conversion strategy, the decoding logic uses the starting offset value corresponding to the current group in the offset index array as a raw pointer base address. It directly dereferences and reads a byte from this base address. The eight binary bits of this byte are interpreted as an unsigned integer in the range of zero to 255. No sign bit extension is performed during the interpretation process, that is, the highest bit is not regarded as a sign flag. This ensures that the key name length identifier variable is always a non-negative integer, which conforms to the semantic constraint of the physical quantity of key name length. Then, the unsigned integer is assigned to the key name length identifier variable for use in subsequent key name copy operations.

[0045] Step S2523: Increment the value of the base address by one to obtain the starting address of the key name byte string. Determine whether the starting address of the key name byte string meets the word alignment access boundary requirements of the central processing unit. If it does not meet the requirements, use a single-byte reading and then shifting and concatenating method to obtain the content of the key name byte string byte by byte.

[0046] The address obtained by adding one to the integer value of the base address is the memory address of the first byte of the key name byte string. Some central processing units have natural alignment requirements for multi-byte memory access, meaning that the starting address of accessing N bytes of data must be an integer multiple of N. If the starting address of the key name byte string does not meet the alignment requirements, but the decoding logic attempts to read it directly with a multi-byte width load instruction, it will trigger a hardware alignment failure or cause serious performance degradation. Therefore, before reading, the decoding logic checks whether the starting address is aligned with the target alignment width boundary. The check is performed by bitwise ANDing the address value with a mask equal to the alignment width minus one. If the result is non-zero, it is determined to be unaligned. In the case of unalignment, the decoding logic adopts a byte-by-byte reading method. Each time, it reads one byte from the corresponding address and temporarily stores it in an integer variable with a width sufficient to accommodate the maximum key name length. After each read, it performs a left shift operation to place the byte into the correct byte channel inside the variable. This process is repeated until the number of bytes equal to the key name length identifier is accumulated, thus bypassing the alignment restriction.

[0047] Step S2524: Starting from the starting address of the key name byte string, read the number of bytes equal to the value of the key name length identifier variable in sequence. Stor the bytes read each time in the character buffer on the thread stack. After all bytes have been read, write the string terminator to the end of the character buffer to obtain the complete key name byte string.

[0048] The character buffer on the thread stack is a fixed-length character array allocated within the function call stack frame. Its length is at least equal to the maximum key name length allowed by the protocol plus one. The decoding logic uses a loop counter. In each iteration, the loop variable is compared with the value of the key name length identifier variable. In the iteration body, a byte is read from the starting address of the key name byte string plus the current iteration count value as the offset, and the byte is written to the corresponding position in the character buffer. After the loop ends, a null character is written as the string terminator in the first empty position after the key name byte length in the character buffer, thereby converting a continuous memory byte sequence into a standard C-style string to form a complete key name byte string.

[0049] Step S2525: Parse the byte order markers that may exist at the beginning of the complete key name byte string. When a byte order marker is detected, convert the complete key name byte string into a key name string using the character encoding / decoding scheme corresponding to the byte order marker. When no byte order marker is detected, call the preset default character encoding / decoding scheme for conversion.

[0050] The first few bytes of the complete key name byte string may contain a special byte order marker, which in the Unicode standard is used to indicate the encoding method and byte order of subsequent text. If the decoding logic detects a byte sequence at the beginning of the complete key name byte string that exactly matches the known binary pattern of the byte order marker, it selects the corresponding scheme from the registered character encoding / decoding scheme list according to the marker and transcodes the remaining bytes of the complete key name byte string, converting it into the character encoding format uniformly used internally by the message queue broker layer. If no known byte order marker is detected, the decoding logic reverts to the preset default character encoding / decoding scheme, which can be a multi-byte character encoding converter consistent with the operating system's locale setting. This converter interprets the complete key name byte string as text under the default character set and converts it into the internally unified format, ultimately obtaining a key name string that the program can process.

[0051] Step S2526: Use the converted key name string as the key name of the current group key-value pair, associate it with the subsequently read value area byte string, and increment the group number of the offset index array. Continue to perform the key name length identifier reading operation on the next group key-value pair using the incremented group number, until the group number exceeds the total number of key-value pairs.

[0052] Before retrieving the key name string and entering the value area byte string reading process, the decoding logic associates the key name string with the group number of the current key-value pair in the offset index array. It reserves space by inserting an entry with the key name string as the key and a placeholder empty byte string as the value into a temporary key-value pair set. This placeholder entry will be overwritten with the actual value area byte string after the value area byte string is read. Then, the decoding logic increments the group number variable in the offset index array by one and compares the incremented group number with the total number of key-value pairs. If the group number is less than the total number of pairs, it retrieves the starting offset of the next group from the offset index array based on the new group number and jumps back to the key name length identifier reading step to continue decoding a new group of key-value pairs. If the group number is equal to the total number of pairs, it exits the loop, completing the decoding of all key-value pairs within the custom attribute segment.

[0053] Step S253: Starting from the starting address of the key name byte string, read the number of bytes indicated by the length of the key name byte string continuously to obtain the original key name byte string. Check the character encoding mark byte of the original key name byte string and decode the original key name byte string into a key name string according to the encoding type indicated by the character encoding mark byte.

[0054] After determining the key name byte length using the key name length identifier, the decoding logic sequentially reads a specified number of bytes from the starting address of the key name byte string. This byte sequence is the raw key name byte string before character encoding interpretation. The first byte or the first few bytes of this raw key name byte string are designated as character encoding marker bytes by the protocol. Their values ​​correspond one-to-one with a set of predefined character encoding types, including U.S. Standard Interchange Code (SIC), Universal Multi-Octet Character Set Conversion Format (UMCSC) 8-bit representation, and UMCSC 16-bit little-endian representation. The decoding logic reads the value of this marker byte and searches for the corresponding encoding / decoding function pointer in the character encoding scheme registry. If a match is found, the function is called to convert the bytes following the marker byte in the raw key name byte string into the internal unified character representation of the key name string. If the marker byte value is not within the known enumeration range, the raw key name byte string is interpreted as a whole as UIC bytes, with each byte directly mapped to a character, thus completing the decoding and obtaining the key name string.

[0055] Step S254: Read two bytes of value area byte length identifier after the end of the key name byte string, parse the value area byte length identifier into the value area byte length, continue to read one byte of compression flag bit, and perform the value area byte string reading operation according to the value area byte length and compression flag bit.

[0056] The end position of the key name byte string is calculated by adding the key name byte string's length to its starting address. The decoding logic moves the read pointer to this end position and reads two bytes consecutively from that position. These two bytes together constitute the value area byte length identifier, which is interpreted as an unsigned short integer value and assigned to the value area byte length variable. This variable indicates the number of bytes occupied by the value area byte string in its uncompressed or compressed state. The read pointer moves forward one byte after these two bytes; this byte is the compression flag. The decoding logic reads its value into a Boolean variable. If the compression flag is a true binary value, it indicates that the subsequent number of bytes indicated by the value area byte length is a byte string processed by a compression algorithm and needs to be decompressed before use. If the compression flag is a false value, it indicates that the subsequent bytes are the original value area byte string itself and do not need to be decompressed. Subsequently, the decoding logic continues to read a number of bytes from the current read pointer position that is exactly equal to the value area byte length, and passes the read byte string along with the value of the compression flag to the value area processing subroutine.

[0057] Step S255: When the read compression flag is set, the number of bytes indicated by the length of the subsequently read value area byte is used as the compressed value area byte string, and the compressed value area byte string is decompressed to recover the original value area byte string. When the compression flag is reset, the number of bytes indicated by the length of the read value area byte is used as the original value area byte string.

[0058] When the compression flag is set, the decoding logic treats the number of bytes indicated by the value area byte length as input and calls a pre-registered decompression algorithm to decompress it. This decompression algorithm can be a variant of a dictionary-based compression algorithm or a lightweight decompression algorithm based on run-length encoding. The decompression algorithm reads control instructions and original data segments one by one from the input byte stream, reconstructs the data segments to the output buffer according to the copy offset and length indicated by the instructions, until the input byte stream is exhausted. The continuous byte sequence in the output buffer is the recovered original value area byte string. If the compression flag is reset, the decoding logic skips the decompression step and directly uses the number of bytes indicated by the value area byte length read from the message frame as the original value area byte string, and directly records its pointer and length information in the current entry of the temporary key-value pair set.

[0059] Step S256: Combine the decoded key name string with the corresponding original value area byte string to form a set of restored key-value pairs and store them in a temporary key-value pair set. If a key-value pair with the same key name string already exists in the temporary key-value pair set, then use the current restored key-value pair to overwrite the existing key-value pair until all sets of key-value pairs in the offset index array have been processed.

[0060] After the key name string and value area byte string are ready, the decoding logic constructs a restored key-value pair structure. This structure contains a pointer to a copy of the key name string and a structure pointing to a copy of the value area byte string and its length descriptor. Then, the decoding logic searches the temporary key-value pair set using the key name string as the lookup key. If an existing entry is found, the old value area byte string memory for that entry is released, and the new value area byte string and its length are overwritten. If no existing entry is found, a new entry is added to the temporary key-value pair set, and copies of the key name string and value area byte string are stored there. This process is repeatedly executed using the group number of the offset index array as the loop driver. The loop exits when the group number is greater than or equal to the total number of key-value pair groups. At this point, all key-value pairs pre-filled by the message producer in the custom attribute section have been restored and temporarily stored in the temporary key-value pair set.

[0061] Step S260: In the temporary key-value pair set, retrieve the key-value pair whose key name is equal to the business unique key constant string, read the value area byte string of the key-value pair and convert it into the business unique key string, retrieve the key-value pair whose key name is equal to the target state transition identifier constant string, read the value area byte string of the key-value pair and convert it into the target state transition identifier string, and encapsulate the two strings obtained by conversion into the message processing context structure and pass them to the subsequent processing stage.

[0062] The business-unique key constant string is an immutable string literal agreed upon in the interface specification between the message queue broker layer and all message producers. For example, its value is fixed as a semantic combination of the business-unique key in English. This string will not easily change with version evolution to ensure that the decoding logic can accurately match the key-value pair carrying the business-unique key information. The target state transition identifier constant string is also another fixed string literal agreed upon in the interface specification, used to locate the key-value pair carrying the target state transition identifier. The decoding logic calls a lookup function on the temporary key-value pair set with these two constant strings as parameters. Internally, the lookup function performs a byte-by-byte equality comparison on all keys in the temporary key-value pair set. When a completely matching key name is found, the value byte string of that key-value pair is extracted, and a byte-to-string function is called. This function first checks if the value byte string ends with a null character and infers its length accordingly. Then, it uses the same character encoding scheme as the key name decoding stage to convert the byte string into an internal string object, thus obtaining the business-unique key string and the target state transition identifier string. The message processing context structure is an aggregate data type constructed on the stack. Its members include at least one pointer to a business unique key string, one pointer to a target state transition identifier string, one pointer to the original message frame to be delivered, and the current timestamp. The decoding logic fills the pointers of the two strings obtained by conversion into the corresponding members of the structure, and passes the address of the structure to the subsequent projection state machine query and state transition processing stage, thus completing all the work in the message header parsing stage.

[0063] Step S300: Based on the read business unique key, perform a query and match in the set of projection state machine instances maintained by the message queue broker layer to obtain the target projection state machine instance associated with the business unique key, and extract the current projection state of the business instance from the target projection state machine instance.

[0064] In one embodiment, step S300 may specifically include the following steps S310 to S360: Step S310: Perform bit-by-bit perturbation mixing operation on each character unit in the business unique key string to generate a hash bucket index value with a fixed bit width. Select a hash bucket as the target hash bucket from the hash table array of the projection state machine instance set using the hash bucket index value. Each hash bucket in the hash table array maintains a candidate projection state machine instance linked list.

[0065] Bitwise perturbation hybrid operation is a hash algorithm that uniformly distributes a variable-length string across a finite integer space. This algorithm takes the memory byte sequence of the business-unique key string as input, initializes a fixed-width accumulator variable to zero, reads each character unit of the business-unique key string byte by byte, shifts the accumulator variable left by a fixed perturbation bit after each byte read, XORs the original accumulator variable with the shifted value, and adds the integer value of the current byte. After traversing all bytes, XORing the accumulator variable with its own value shifted right by a different perturbation bit is performed again to further diffuse high-order information through an avalanche effect. Finally, the accumulator variable is modulo the total number of slots in the hash table array, and the result is the hash bucket index value.

[0066] The hash table array is a contiguous array of pointers allocated in shared memory. Each slot in the array is a hash bucket, and each hash bucket stores a pointer to the head node of the linked list of candidate projected state machine instances. A read-write lock is attached to protect against concurrent access to the linked list. After obtaining the hash bucket index, the message processing logic calculates the offset address of the target hash bucket within the hash table array. This offset is calculated by adding the hash bucket index to the base address of the hash table array and the product of the hash bucket index and the size of a single hash bucket structure. Subsequent linked list traversal operations are performed within the range of this target hash bucket.

[0067] Step S320: Obtain the bucket-level read lock of the target hash bucket, read the head pointer of the candidate projected state machine instance linked list within the interval holding the bucket-level read lock, start traversing along the linked list node pointed to by the head pointer, and perform a byte-by-byte binary full equality comparison between the instance business unique key field stored in each linked list node and the business unique key string.

[0068] Bucket-level read locks are read-side primitives of read-write locks. Multiple threads can simultaneously hold the bucket-level read lock for the same hash bucket to perform concurrent linked list traversal and query operations. However, when a thread holds the bucket-level write lock, all threads attempting to acquire the read lock will be blocked. This strategy maximizes query-side concurrency throughput while ensuring the atomic visibility of the projected state machine instance insertion operation. The message processing logic calls the bucket-level read lock acquisition interface after entering the hash bucket. Upon successful acquisition, it reads the head pointer value of the candidate projected state machine instance linked list from the target hash bucket's structure. Each node in the linked list embeds a pointer to a projected state machine instance and a pointer to the successor node. The nodes themselves can be distributed across different locations in the memory pool.

[0069] The traversal process starts from the head node of the linked list. Inside a loop, it first checks whether the current node is the end sentinel node of the linked list. If not, it accesses the projected state machine instance pointed to by the pointer inside the node, and then reads the starting address of the storage area where the instance's business unique key field is located. Starting from this address, it performs a byte-by-byte binary equality comparison with the character sequence of the business unique key string in the message processing context structure. That is, it compares the value of each byte in the two byte sequences at the same offset. If all bytes are equal and both sequences reach their respective terminating null characters at the same time, it is determined that the match is successful.

[0070] Step S330: When the instance business unique key field of a certain linked list node is found to be completely consistent with the business unique key string during the traversal, the projection state machine instance pointed to by the linked list node is determined as the target projection state machine instance, and then the traversal is stopped and the bucket-level read lock is released.

[0071] When the binary byte-by-byte comparison returns true at a node in the linked list, the message processing logic assigns the pointer to the projected state machine instance of that node to a target projected state machine instance pointer variable. It then temporarily prevents the target projected state machine instance from being garbage collected by atomically incrementing its internal reference count. Afterward, it exits the traversal loop and calls the bucket-level read lock release interface to return the bucket-level read lock, allowing other threads to immediately acquire the read or write lock for that hash bucket. The locked target projected state machine instance is now exclusively referenced by the current message processing context, allowing subsequent current projected state retrieval operations to be performed safely without worrying about the instance being deleted and its memory released by other threads during the retrieval process.

[0072] Step S340: When the last sentinel node of the candidate projection state machine instance list is still not matched, record the miss state and release the bucket-level read lock. Then, request a free memory block with the same size as the projection state machine instance structure from the memory allocator of the message queue broker layer.

[0073] In one embodiment, step S340 may specifically include the following steps S341 to S346: Step S341: Access the free memory block linked list maintained by the memory allocator of the message queue broker layer, check whether there is a node in the free memory block linked list whose size is greater than or equal to the size of the projected state machine instance structure, if it exists, remove the node from the linked list and return its address.

[0074] The memory allocator maintains a hierarchical linked list of free memory blocks within the message queue broker layer. Each linked list corresponds to a size level, and the size of the projected state machine instance structure is mapped to one of these levels. The message processing logic aligns the size of the projected state machine instance structure upwards to the nearest size level boundary, and then uses this aligned size as the key to index the corresponding free memory block linked list. If the linked list is not empty, the first free node is removed from the head of the list, its address and block size are recorded in the allocation result structure, and the result is returned. The removal operation is performed using atomic comparison-swap instructions to ensure concurrent correctness when multiple threads simultaneously request memory.

[0075] Step S342: If there is no matching node in the free memory block list, a new physical memory page is obtained by sending a memory allocation request to the operating system. The physical memory page is then divided into multiple unit blocks of uniform size, each the size of a projected state machine instance structure. The extra unit blocks are linked to the free memory block list for later use.

[0076] When the free memory block list for the corresponding size level is empty, the memory allocator calls the anonymous memory mapping interface provided by the operating system to request a new physical memory page with a size that is an integer multiple of the system page size. This physical memory page is mapped to an unoccupied region in the virtual address space of the message queue agent layer process. The memory allocator then divides this contiguous physical memory page into equal-distance segments according to the size of the projected state machine instance structure. Starting from the page start address, a unit block boundary is marked at intervals of the size of the projected state machine instance structure. Each unit block is treated as an independent free memory block. Except for the first unit block, which is reserved for this return, the remaining unit blocks are inserted one by one into the corresponding level of the free memory block list. During insertion, the forward and backward pointers at the head of the unit block are modified, and memory barriers are used to achieve lock-free or fine-grained lock-based concurrent safe links.

[0077] Step S343: Align the starting address of the obtained free memory block with the cache line size. If the starting address is not aligned with the cache line boundary, adjust the address offset so that the starting address of the actual memory region falls within the cache line alignment boundary.

[0078] The cache line size is the minimum data block length managed by the central processing unit's cache coherence protocol. In multi-core systems, if two frequently written variables are located within the same cache line, a false sharing problem can occur, causing the cache line to repeatedly jump between cores. The message processing logic performs a bitwise AND operation on the starting address of the free memory block returned by the memory allocator with a mask equal to the cache line size minus one. If the result is zero, it indicates that the memory is aligned. If the result is not zero, the starting address is added to the cache line size and then the non-zero remainder is subtracted to obtain a new starting address. At the same time, it is necessary to ensure that the adjusted memory region is still completely within the boundary of the original free memory block. After adjustment, any extra leading bytes and tail space that may be insufficient for a single projected state machine instance are marked as filler fragments and will not be used for actual instance storage.

[0079] Step S344: Fill the adjusted memory block area with zero values ​​byte by byte, copy the character sequence of the business unique key string byte by byte to the specified offset of the index field area in the memory block, and append a string termination identifier to the end after the copy is completed.

[0080] The message processing logic obtains the starting address of the aligned memory block and calls the memory zeroing function to write all bits of the projected state machine instance structure (size x bytes) starting from that address to binary zero. This operation ensures that all fields in the projected state machine instance are initially expected to have zero values ​​or null pointers. Subsequently, the message processing logic performs a byte-by-byte serial copy, using the character pointer of the business unique key string as the source address and the specified offset of the index field area in the memory block as the destination address. The number of bytes copied is equal to the length of the business unique key string plus one. The purpose of adding one is to also copy the terminating null character of the source string to the target area to ensure that subsequent string comparison operations can correctly identify the end of the string.

[0081] Step S345: Copy the name identifier constant string of the default starting abstract state node to the state storage area in the same way, and call the cache line refresh instruction to write the cache line where the state storage area is located back to the main memory to ensure visibility between multi-core processing units.

[0082] The default starting abstract state node's name identifier constant string is a globally defined immutable string that strictly corresponds to the first abstract state node in the full lifecycle state chain. When a new projection state machine instance is created, this string must be written to the state storage area as the initial value of the current projection state. The message processing logic copies this constant string byte-by-byte to the specified offset in the state storage area of ​​the projection state machine instance structure, and writes a terminating null character at the end after the copy is complete. Next, the message processing logic calculates the address range of all cache lines spanned by the state storage area, using the starting address as a reference. It then executes a cache line flush instruction on each of these cache lines, forcibly writing the data of the corresponding cache line in the cache back to main memory and invalidating the copies of that cache line in other cores. This ensures that once the projection state machine instance is inserted into the hash table, threads in other cores can immediately see the complete and correct current projection state.

[0083] Step S346: Set the reference count of the projection state machine instance corresponding to the memory block to the initial active value, and forcibly convert the starting address of the memory block to the projection state machine instance pointer type, thus completing the conversion from the free memory block to the projection state machine instance.

[0084] The reference count is an integer field within the projected state machine instance structure. It tracks how many concurrent message processing contexts or management threads are currently referencing the instance. The initial active value is typically set to the integer constant one, indicating that one processing context currently holds a reference to the instance. The message processing logic casts the starting address of the memory block to a pointer type of the projected state machine instance. This casting is done through explicit type conversion syntax, without changing the actual binary content in the memory block. However, it provides the correct type perspective for subsequent code to access fields in the memory block according to the structure layout of the projected state machine instance. At this point, the free memory block is semantically elevated to a fully functional projected state machine instance.

[0085] Step S350: Write the length and content of the business unique key string into the index field area of ​​the free memory block, write the name identifier of the default starting abstract state node into the state storage area, write the current system time into the entry timestamp marker area, and write an empty identifier into the previous successfully executed state transition marker area.

[0086] After completing the type conversion from memory block to projection state machine instance, the message processing logic writes the length and full byte content of the business unique key string byte by byte into the index field area of ​​the projection state machine instance, in the same way as copying the character sequence in step S344. Simultaneously, it writes the name identifier constant string of the default starting abstract state node into the state storage area, assigning the correct initial state to the newly created projection state machine instance. The entry timestamp marker area is written with the current system time obtained from the system's high-precision clock source. This time value identifies the point in time when the projection state machine instance was created and first entered the message queue broker layer's maintenance scope. The previous successfully executed state transition marker area is written with an empty identifier, which is either a predefined string of zero length or a special state constant indicating that no transition has occurred, used to indicate that the projection state machine instance has not yet undergone a state transition.

[0087] Step S360: Reacquire the bucket-level write lock of the target hash bucket, insert the linked list node corresponding to the initialized free memory block into the head of the candidate projection state machine instance linked list, perform a memory barrier operation, release the bucket-level write lock, and determine the projection state machine instance as the target projection state machine instance. Then, extract the current projection state from the state storage area of ​​the instance.

[0088] In one embodiment, step S360 may specifically include the following steps S361 to S366: Step S361: Before attempting to acquire the bucket-level write lock, first fill the business unique key field and the current projection state field inside the initialized projection state machine instance to the final consistent state, and perform write merging optimization on the cache lines containing the business unique key field and the current projection state field to eliminate fragmented write operations.

[0089] Before entering write lock contention, the message processing logic ensures that all externally visible fields of the projection state machine instance are filled to the final state, avoiding time-consuming field filling operations during lock holding, which would prolong lock holding time. Write merging optimization refers to merging multiple scattered write operations targeting different offsets within the same cache line into a single continuous full cache line write. The central processing unit's write merging buffer automatically merges write operations belonging to the same cache line before sending them to the next-level cache. By ensuring that the write addresses of the business unique key field and the current projection state field are continuous and cover the entire cache line at once, the message processing logic prompts the processor to merge multiple write instructions into a single cache line fill, thereby significantly reducing the occupation of the shared memory bus.

[0090] Step S362: Execute a write memory barrier instruction. The write memory barrier instruction forces all pending write operation results in the current processing core's storage buffer to be propagated down to the shared cache level and finally to main memory, in order to prevent subsequent pointer update operations from being detected by other processing cores before the data is completely written.

[0091] The write memory barrier instruction is a memory ordering primitive provided by the processor's instruction set architecture. It inserts an insurmountable barrier between all memory operations before and after its execution. The message processing logic calls the write memory barrier instruction after merging the writes to the business unique key field and the current projected state field. This instruction flushes the write results from the current core's memory buffer to the last-level cache and even main memory, ensuring that when the linked list pointer is updated, making the projected state machine instance globally visible, all writes to its internal fields have been completed under the hardware memory model and are visible to remote cores.

[0092] Step S363: After the write memory barrier instruction is executed, acquire the bucket-level write lock of the target hash bucket, read the current head pointer value of the candidate projected state machine instance linked list, and assign the successor pointer field of the linked list node to be inserted to the current head pointer value.

[0093] Since the write memory barrier has guaranteed the integrity of the data within the instance to be published, the message processing logic can safely initiate a request to acquire the bucket-level write lock of the target hash bucket. Upon successful acquisition, it exclusively acquires write access to that hash bucket. Next, the message processing logic reads the current head pointer value of the candidate projected state machine instance linked list from the hash bucket's control structure. This value is either an absolute memory address or a null pointer. The message processing logic then directly assigns the current head pointer value to the successor pointer field of the linked list node allocated to the new projected state machine instance, making the new node point to the first real node in the current linked list, preparing for the subsequent atomic head pointer update.

[0094] Step S364: Update the head pointer of the candidate projected state machine instance linked list from the current head pointer value to the address of the linked list node to be inserted through an atomic comparison swap operation. If the atomic comparison swap operation fails because the head pointer is modified concurrently, the latest head pointer value is read again and the atomic comparison swap is tried again until it succeeds.

[0095] An atomic comparison-swap operation is an atomic instruction provided by the processor. This instruction accepts three operands: the target memory address, the expected old value, and the new value to be written. Only if the current value at the target memory address is exactly equal to the expected old value will the new value be written to the target memory address and a success indication be returned; otherwise, the target memory address will not be modified and the current actual value will be returned. The message processing logic uses the address of the head pointer field in the hash bucket as the target memory address, the current head pointer value as the expected old value, and the address of the newly allocated linked list node as the new value, and performs an atomic comparison-swap. If, due to concurrent insertion, the head pointer is modified by another thread after being read, the atomic comparison-swap will fail. The message processing logic retrieves the latest head pointer value from the failure return, uses it as the new expected old value, updates the successor pointer of the node to be inserted, and then initiates the atomic comparison-swap again. This retry loop terminates when the atomic comparison-swap returns successfully.

[0096] Step S365: After the atomic comparison swap operation returns successfully, immediately execute a read memory barrier instruction. The read memory barrier instruction invalidates the prefetch queue of the current processing core, forcing subsequent linked list traversal operations to reload the head pointer and the content of the node it points to from main memory or shared cache.

[0097] A successful atomic comparison swap signifies that the linked list node corresponding to the new projected state machine instance has been officially linked to the head of the hash bucket's linked list. At this point, other cores can traverse to the new node by reading the head pointer. To ensure that subsequent traversals of the linked list by the current thread or other threads accurately see the latest head pointer and the data inside the new node, the message processing logic executes a read memory barrier instruction immediately after the atomic comparison swap. The read memory barrier instruction clears the prefetch queue and load buffer of the current processing core, ensuring that any read instruction after this instruction must reload data from the storage hierarchy, rather than using an old copy prefetched into the core before the barrier. This measure eliminates the potential data misalignment problem that can occur on weak memory order processors.

[0098] Step S366: After the read memory barrier instruction is executed, release the bucket-level write lock and complete the insertion of the projected state machine instance into the candidate projected state machine instance linked list.

[0099] After confirming that all memory order guarantees are in place, the message processing logic calls the bucket-level write lock release interface to unlock the write lock, thereby releasing the block on other threads waiting to read or write to this hash bucket. At this point, a new projection state machine instance has been fully incorporated into the projection state machine instance set in a thread-safe manner and can be queried and matched by all subsequent message processing contexts targeting the same business unique key.

[0100] Step S400: Compare the target state transition identifier with the extracted current projected state input to the preset state transition rule set, and determine whether the transition from the current projected state to the abstract state node pointed to by the target state transition identifier conforms to the legal transition path defined in the preset state transition rule set.

[0101] In one embodiment, step S400 may specifically include the following steps S410 to S460: Step S410: Extract a list of directed edges starting from the current projection state from the set of state transition rules bound to the target projection state machine instance. Each directed edge in the list records the name identifier, transition type descriptor, and join flag of the endpoint abstract state node.

[0102] The target projection state machine instance holds a pointer to its bound set of state transition rules in its additional extended data area. This set of state transition rules may be unique to the business type to which the instance belongs, or it may be a global set of rules shared by all delivery business instances. The message processing logic uses the extracted name identifier string of the current projection state as the key to perform a fast lookup in the adjacency list of the state transition rule set. The adjacency list is implemented in memory as a hash map, where the key is the name identifier of the starting abstract state node, and the value is an array of structures containing multiple directed edge records. Each directed edge record is a fixed-length structure that contains at least one string field storing the name identifier of the ending abstract state node, an enumeration field storing the transition type descriptor, and a boolean field storing a join flag. The join flag indicates whether the state transition needs further checks on the current projection states of other related business instances to finally determine its validity.

[0103] Step S420: Traverse the list of directed edges. For each directed edge in the list, perform a string equality comparison between the name identifier of the endpoint abstract state node and the name identifier of the abstract state node pointed to by the target state transition identifier, until a completely matched directed edge is found and marked as a candidate directed edge.

[0104] The message processing logic performs a linear traversal on the directed edge list, iterating from the first element to the last. For each iteration, the logic extracts the endpoint abstract state node name identifier string from the current directed edge record and performs a string equality comparison with the target state transition identifier string stored in the message processing context structure. The string equality comparison first checks if the two strings have the same length; if not, it's considered a mismatch. If the lengths are equal, it compares the character values ​​at the same offset byte by byte; if all characters are equal, it's considered a perfect match. Once a perfectly matched directed edge is found, the message processing logic records its pointer to a candidate directed edge variable and stops the traversal. If no perfectly matched directed edge is found after traversing the entire directed edge list, it means there is no valid directed edge between the current projected state and the abstract state node pointed to by the target state transition identifier, and subsequent checks will directly generate a non-compliance conclusion.

[0105] Step S430: Read the set state of the linkage flag bit of the candidate directed edge. When the linkage flag bit is not set, skip the external state constraint verification process, generate a judgment signal that the comparison result is consistent, and output the transition type descriptor of the candidate directed edge as the transition type flag of this transition.

[0106] The state of the join flag determines whether the transition needs to trigger cross-instance state constraint verification. The message processing logic reads the boolean value of the join flag field in the candidate directed edge structure. If the value is false (not set), it indicates that the business rule believes that this state transition only depends on the current projected state of the current business instance and does not need to refer to the state of any other business instance. In this case, the message processing logic directly constructs a judgment signal structure that matches the comparison result. In this structure, the transition type descriptor of the candidate directed edge is assigned to the transition type flag field, and the judgment conclusion is set to match. Then, all external state constraint verification processes are skipped and the message delivery decision is directly entered. Thus, a simple state transition, such as the transition from order initialization to pending merchant confirmation, can be verified as quickly as possible.

[0107] Step S440: When the joint query flag is set, extract the external business instance type identifier and the storage offset of the target external state constraint from the additional data area preset by the candidate directed edge, and load the content of the target external state constraint in the additional storage area of ​​the target projected state machine instance according to the storage offset.

[0108] A true check flag indicates that the state transition is constrained by the state of an external business instance. For example, before transitioning from "delivery in transit" to "pickup order," it might be necessary to verify whether the number of other ongoing orders under the rider's name has reached the system's set limit, or to verify whether the merchant's associated shipping warehouse is in a shippable state. The supplementary data area of ​​the candidate directed edge is a variable-length memory region immediately following the fixed-length structure of the directed edge. This region stores an external business instance type identifier string and the storage offset of the target external state constraint in a predetermined format. The external business instance type identifier string is used to filter out instances belonging to the same business type from all currently active projected state machine instances in the message queue broker layer. The target external state constraint describes the set of states that these associated instances need to satisfy. The message processing logic, based on the storage offset, treats this offset as the base address offset of the supplementary storage area of ​​the target projected state machine instance. It loads the complete serialized content of the target external state constraint from this offset position in the supplementary storage area and deserializes it into an allowed state set structure in memory.

[0109] Step S450: Using the external business instance type identifier as a filtering condition, select the active instance set with the same business type from all currently alive projection state machine instances in the message queue broker layer, read the current projection state of each instance in the active instance set in turn, and perform an inclusion check between each read current projection state and the allowed state set defined in the target external state constraint.

[0110] In one embodiment, step S450 involves performing an inclusion check between each currently projected state and the set of allowed states defined in the target external state constraints. This may specifically include the following steps S451 to S456: Step S451: Parse the contents of the target's external state constraints, extract the set of allowed states organized in list form, where each element in the set of allowed states is a name identifier string of an abstract state node, and calculate the total number of elements in the set of allowed states.

[0111] The external state constraints of the target are serialized using a compact list encoding format. The list header stores the total number of elements, followed by the string length and byte sequence of each element stored sequentially. The message processing logic reads a short integer from the storage offset as the total number of elements, and then repeatedly reads the length prefix and corresponding byte sequence of the next element in a loop. Each time a complete string is read, it is added to a dynamic array. After the loop ends, the dynamic array contains the parsed set of allowed states, and the number of its elements is recorded in an auxiliary variable for use in subsequent steps.

[0112] Step S452: Construct a set of bit positions for fast negation judgment for the set of allowed states. Traverse the set of allowed states, perform a hash operation on the name identifier string of each abstract state node, map the hash result to a bit offset, and set the corresponding bit in the set of bit positions to a valid state.

[0113] The bit position set is a contiguous storage area for bits. Each bit can only take two values: valid or invalid. When using it for inclusion checks, most cases not in the set can be quickly eliminated through bit-by-bit testing with constant time complexity, significantly reducing the number of subsequent string-by-string equality comparisons. The construction process begins by traversing the set of allowed states. For each name identifier string, a hash operation is performed. The hash operation uses multiple independent hash functions to calculate the hash value. Each hash value is modulo the total number of bits in the storage to obtain a bit offset. Then, the bit position at that offset is set as the valid state in the bit position set storage.

[0114] In one embodiment, step S452 involves constructing a set of bit positions for fast negation judgment for the set of allowed states, which may specifically include the following steps S4521 to S4526: Step S4521: Determine a contiguous memory region of a size that can accommodate the expected maximum number of bits as the storage body for the set of bit positions, and initialize all bytes of the storage body to zero, so that all bits are in an invalid state.

[0115] The expected maximum number of bits is an integer configured based on the possible upper bound of the target external state constraints. At startup, the message queue broker pre-allocates a contiguous memory region satisfying this upper bound as the storage for the bit location set for each worker thread. When constructing the bit location set, all bytes in this storage are first filled with zeros. This zeroing operation is efficiently completed by calling a memory zeroing function or using a single-instruction multiple-data instruction. After zeroing, each bit in the storage represents an invalid state.

[0116] Step S4522: Determine the number of hash functions to be used. For each abstract state node name identifier string in the allowed state set, calculate the hash value using each hash function. Take the modulo of each hash value with the total number of bits in the storage to obtain multiple bit offsets.

[0117] The number of hash functions is a preset small integer. The message processing logic calls all hash functions for each name identifier string. Each hash function takes the string's byte sequence as input and generates a wide-bit hash value through mixed multiplication, shifting, and XOR operations. Then, it performs a modulo operation on the wide-bit hash value and the total number of bits in the storage bank. The result of the modulo operation is a bit offset. Each name identifier string generates a bit offset equal to the number of hash functions during each construction process.

[0118] Step S4523: For each of the multiple bit offsets, calculate the byte address and bit mask of the corresponding bit offset in the memory, and set the bit indicated by the bit mask at the byte address to the valid state through an atomic bitwise OR operation.

[0119] The byte address is calculated by right-shifting the bit offset by the logarithm of the number of bits in the byte. The quotient is the byte offset relative to the starting address of the memory bank, and the remainder determines the specific bit position within that byte. The bitmask is an 8-bit constant where only the specified bit position within the byte is valid, and the rest are zero. It is obtained by left-shifting the constant by the remainder. The message processing logic uses an atomic bitwise OR operation to perform a bitwise OR between the byte at the specified memory address and the bitmask, and writes the result back to ensure that bit settings are not interfered with by race conditions in concurrent read / write scenarios.

[0120] Step S4524: After hashing and setting all the abstract state node name identifier strings in the allowed state set, a conflict check storage area is added to the storage body. The conflict check storage area stores a complete copy of each abstract state node name identifier string in the form of an associative list.

[0121] The bit location set itself cannot completely avoid hash collisions; that is, two different name identifier strings may produce the exact same bit position pattern in the storage due to hash collisions. To solve this problem, in the final stage of bit location set construction, the message processing logic allocates a collision resolution storage area. This storage area is organized using a hash-associative list. A complete copy of each name identifier string in the allowed state set is inserted into this association list as a key. Each node in the association list stores a copy of the string and a pointer to the next node to resolve intra-bucket collisions.

[0122] Step S4525: After the inclusion check of the current projection state string is performed and the bit position set gives an indication of possible existence, the collision check storage area is entered. An exact match search is performed in the association list with a complete copy of the current projection state string. The inclusion relationship is finally confirmed only when the exact match search is successful.

[0123] The subsequent inclusion check process first queries the bit location set. If all relevant bits are in a valid state, the bit location set report may exist. However, a conclusion cannot be drawn directly at this point; the conflict check storage area must be entered. In the conflict check storage area, the message processing logic calculates the hash value based on the current projected state string and locates the bucket in the associated list. Then, it performs an equality comparison on each complete copy of the current projected state string and the string stored in the linked list node within the bucket. If an equality match is found, the inclusion relationship is finally confirmed; otherwise, the bit location set report is considered a false positive due to a hash collision, and the inclusion relationship is not actually valid.

[0124] Step S4526: All access operations to the bit location set adopt a lock-free read method, while access to the conflict check storage area is performed by adding a lightweight read lock on the read side to ensure the correctness of the inclusion check process under multi-threaded concurrent access.

[0125] Once constructed, the storage for the bit position set is read-only, allowing multiple threads to simultaneously read the bit states without any locks or synchronization. Because the conflict check storage area may concurrently experience write operations inserting new strings during queries, a lightweight read lock is used on the read side. This read lock allows multiple inclusion checks to be performed simultaneously, only briefly blocking readers when the conflict check storage area is resized or an insertion operation occurs. This design minimizes lock contention overhead while ensuring correctness.

[0126] Step S453: When it is necessary to perform an inclusion check on the current projection state string of an active instance, first perform the same hash operation and mapping operation on the current projection state string, check whether the corresponding bit in the bit position set is in a valid state, and if it is in an invalid state, return a result of not including.

[0127] The message processing logic takes the current projected state string to be checked as input, uses the same set of hash functions and modulo operations as when constructing the bit position set, calculates several bit offsets, and then sequentially reads the bit values ​​at these offsets from the bit position set storage. If any bit at any offset is found to be invalid, it can be absolutely determined that the current projected state string cannot be in the allowed state set, immediately returning a "no inclusion" result and terminating all subsequent checking steps. This fast rejection mechanism significantly reduces the average time overhead of each round of inclusion checks.

[0128] Step S454: If the corresponding bit in the bit position set is in a valid state, start the precise string comparison process and perform a byte-by-byte equality comparison between the current projected state string and each element in the allowed state set.

[0129] When all checked bits in the bit position set are in a valid state, the inclusion check enters the precise string comparison process. The message processing logic traverses the dynamic array of allowed state sets, performs a byte-by-byte equality comparison between the current projected state string and each name identifier string in the array. The comparison algorithm is the same as the string equality comparison in step S420, first comparing the length, and if the lengths are the same, comparing the string content byte by byte.

[0130] Step S455: When a completely identical match is found in the allowed state set by byte equality comparison, return a result containing the match and terminate subsequent comparisons. When no match is found after traversing all elements of the allowed state set, return a result not containing the match.

[0131] During the traversal of the allowed state set, once a byte-by-byte equality comparison returns a true value, the inclusion check function immediately constructs and returns the included result, without continuing to compare the remaining elements; if no matching element is found after traversing the entire allowed state set, the function constructs and returns the excluded result, which will participate in the generation of subsequent comparison and determination signals.

[0132] Step S456: The returned result of inclusion or non-inclusion is taken as the final conclusion of the inclusion check and used to drive the generation of subsequent comparison judgment signals.

[0133] The message processing logic records the Boolean value conclusion obtained in step S455 in the inclusion check result variable. This variable is then passed to the assembly process of the comparison decision signal to determine whether the currently checked active instance satisfies the external state constraint conditions, and finally accumulates to form the comparison decision signal.

[0134] Step S460: When the inclusion check result indicates that the current projection state of at least one active instance falls into the set of allowed states, a judgment signal indicating that the comparison result is compliant is generated; otherwise, a judgment signal indicating that the comparison result is non-compliant is generated, and the judgment signal, together with the transition type flag or the reason for the state mismatch, is passed to the message delivery decision stage.

[0135] After performing inclusion checks on all projected state machine instances in the active instance set, the message processing logic summarizes the results of all inclusion checks. If at least one instance's result is inclusion, it indicates that the current external state constraint is satisfied. A matching result determination signal is generated, and the transition type marker recorded in step S430 is filled into the corresponding field of the determination signal structure. If all active instances' inclusion check results are non-inclusion, a matching result determination signal is generated, and a state mismatch reason enumeration value is attached to the structure. This enumeration value precisely indicates which specific business type in the external state constraint and its expected set of allowed states failed to be satisfied. The determination signal structure is encapsulated in the message processing context structure for distribution selection by the message delivery decision logic in step S500.

[0136] Step S500: When the comparison result is consistent, the message queue broker layer sends the message to be delivered to the consumer instance and updates the current projection state of the target projection state machine instance to the abstract state node pointed to by the target state transition identifier. When the comparison result is inconsistent, the message queue broker layer blocks the delivery operation of the message to be delivered and discards or dumps the message to be delivered to the audit queue.

[0137] In one embodiment, in step S500, when the comparison result is consistent, the message queue broker layer sends the message to be delivered to the consumer instance and updates the current projection state of the target projection state machine instance to the abstract state node pointed to by the target state transition identifier. Specifically, this may include the following steps S510 to S560: Step S510: The message queue broker layer finds the network address of the corresponding consumer instance and the current write pointer position of the message receiving buffer in the consumer group topology graph based on the topic partition identifier carried by the message to be delivered, and obtains the transport layer session handle of the target consumer instance.

[0138] The topic partition identifier is a combination of a string and an integer partition number recorded in the message header of the message to be delivered. It is used to logically divide the message space into multiple ordered queues, with each topic partition exclusively consumed by a single consumer instance at any given time. The consumer group topology graph is a dynamic routing table maintained internally by the message queue broker layer. This table is maintained in real-time through heartbeat and election mechanisms, recording the network address, transport layer session handle, and write pointer to the message receive buffer of each consumer instance currently containing each topic partition. The message processing logic performs a hash lookup in the consumer group topology graph using the topic partition identifier as the key. If the lookup is successful, it obtains a consumer routing information structure containing the remote network address and session handle. From this structure, it extracts the transport layer session handle of the target consumer instance. This handle is either a socket file descriptor provided by the operating system or a long-connection object handle encapsulated by the application layer, used for subsequent actual message data transmission.

[0139] Step S520: Write the complete message frame byte sequence of the message to be delivered into the message receiving buffer of the target consumer instance through the zero-copy sending interface. The zero-copy sending interface avoids data copying by mapping the page table entry of the memory page where the message frame is located to the socket sending buffer. After the writing operation is completed, record the delivery completion timestamp.

[0140] After the complete message frame byte sequence is extracted in step S220, it remains unchanged in the memory pool of the message queue broker layer. At this point, the message processing logic calls the zero-copy send interface provided by the operating system. Specifically, this interface passes the starting address and length of the memory region to be sent to the operating system kernel during the call. The kernel directly modifies the page table entry of the socket send buffer, mapping the physical memory page containing the message frame to the socket's send buffer descriptor. This allows the network card to directly read data from this physical memory page via direct memory access when sending data. Throughout the entire send path, the central processing unit does not perform any byte copying from user space to kernel space. After the zero-copy send interface returns, the message processing logic obtains the current timestamp by reading a high-precision clock source and records this timestamp as the delivery completion timestamp in the message processing context structure, indicating that the message has been submitted for transmission at the network protocol stack level.

[0141] Step S530: After confirming that the complete message frame byte sequence has successfully entered the message receiving buffer, construct a state update instruction. The state update instruction includes the service unique key of the target projected state machine instance, the name identifier of the abstract state node pointed to by the target state transition identifier, and the delivery completion timestamp.

[0142] The return value of the zero-copy sending interface confirms that the message frame has been successfully queued in the socket sending queue. The message processing logic uses this as a dividing line to begin constructing the state update instruction. The state update instruction is a lightweight data structure, typically allocated on the stack, containing three fields: a copy of a business-unique key string used to locate the target projected state machine instance whose state needs updating; a name identifier string pointing to the abstract state node of the target state transition, serving as the target state value for this update; and a delivery completion timestamp obtained from step S520, used to maintain time order in the state update queue.

[0143] Step S540: Push the status update instruction into the status update processing queue sorted by delivery completion timestamp. The instructions in the status update processing queue are arranged monotonically in ascending order according to the order of timestamps to ensure that status update instructions for the same business unique key are processed serially in the delivery order.

[0144] In one embodiment, step S540 may specifically include the following steps S541 to S546: Step S541: The status update processing queue consists of a set of skip list nodes organized according to the size of the delivery completion timestamp value. The nodes at each level of the skip list form a multi-level index structure through forward pointers. The push operation first allocates a skip list node for the status update instruction to be pushed and fills it with the business unique key, name identifier and timestamp.

[0145] A skip list is a randomized data structure based on an ordered linked list. It achieves an average time complexity similar to a balanced tree by adding multi-level indexes to the linked list, while maintaining the simplicity of insertion and deletion operations. The message processing logic obtains a pre-allocated skip list node from the node allocator. This node contains an embedded structure storing state update instructions and an array of pointers to store forward pointers at each level. After the node is allocated, the message processing logic copies the business-unique key, name identifier, and timestamp from the state update instruction, field by field, into the instruction storage area inside the node.

[0146] Step S542: Starting from the highest level index of the skip list, move the forward pointer of the current level to the right layer by layer, compare the timestamp of the node pointed to by the forward pointer with the timestamp of the node to be pushed, until the largest node in the current level whose timestamp is smaller than the timestamp of the node to be pushed is found, and record this node as the predecessor of the current level.

[0147] The highest level of the skip list is the sparsest, with the fewest nodes. Starting from this level, searching for the predecessor node allows for rapid skipping of a large number of nodes. Within each level, the message processing logic maintains a current node pointer variable, initially pointing to the head node of that level. Then, in a loop, it continuously compares the timestamp of the node pointed to by the forward pointer of the current node with the timestamp of the node to be pushed. If the timestamp of the node pointed to by the forward pointer is less than the timestamp of the node to be pushed, the current node pointer is updated to the node pointed to by the forward pointer, and the pointer continues to move to the right until the forward pointer is null or the timestamp of the node it points to is greater than or equal to the timestamp of the node to be pushed. At this point, the current node is the predecessor node for that level, and it is recorded in a predecessor node array.

[0148] Step S543: Set the backward pointer of the node to be pushed to the node originally pointed to by the forward pointer of the predecessor node in the current layer, and update the forward pointer of the predecessor node to point to the node to be pushed through an atomic comparison swap operation, thus completing the link insertion in the current layer.

[0149] The message processing logic assigns the pointer entry of the corresponding layer in the pointer array of the node to be pushed to the current value of the predecessor node's forward pointer. Then, using the address of the predecessor node's forward pointer as the target address, the current value as the expected old value, and the address of the node to be pushed as the new value, it performs an atomic comparison and swap operation. If the operation succeeds, the link insertion of the current layer is complete; if it fails due to concurrent insertion, it retryes from the predecessor node search step of that layer until it succeeds.

[0150] Step S544: Following the top-to-bottom order of the index layers, repeatedly perform the operations of finding the predecessor and atomic comparison to exchange links layer by layer, and perform a write memory barrier on the newly inserted pointer field after each layer of linking is completed to ensure the consistency of the pointer change order between skip table layers.

[0151] After the insertion at the highest level of the skip list is completed, the message processing logic sequentially moves to the next level of the index. Starting from the predecessor node determined in the previous level, it quickly finds the predecessor node of the current level and performs the same link insertion and atomic comparison swap. After completing the insertion operation at each level, the message processing logic performs a write memory barrier on the pointer field that was just modified. This write memory barrier ensures that the modification of the lower level pointer has been flushed before the modification of the upper level pointer becomes globally visible. This avoids traversal interruptions caused by other concurrent readers seeing the new upper level pointer but not the correct lower level link when quickly jumping through the upper level index.

[0152] Step S545: After the node to be pushed is successfully inserted into the bottom layer of the skip list, the combination encoding of the business unique key and timestamp of the node to be pushed is registered in a temporary blocking waiting mapping table for matching and wake-up during subsequent state update processing task polling.

[0153] The lowest level of the skip list is the zeroth level index, which is an ordered doubly linked list containing all nodes. Once a node to be pushed is successfully linked to the zeroth level, the message processing logic calculates the combined encoded value of the business unique key and the timestamp, and inserts a record into a global temporary blocking wait map. The key of this record is the combined encoded value, and the value is the address of a semaphore or condition variable. If a state update processing task is waiting for an update instruction for this business unique key, it can be woken up through this map.

[0154] Step S546: The status update processing task continuously polls the lowest-level head node of the skip list. When it finds that the timestamp of the head node is less than or equal to the current system time, it removes the head node from the skip list and removes the corresponding entry from the blocking waiting mapping table according to the business unique key. Then, it processes the status update instructions in the removed node.

[0155] The state update processing task is a persistent background thread. Within a loop, this thread repeatedly checks the head node of the lowest level of the skip list, reads the timestamp field of the instruction within the head node, and compares it with the current system time. If the timestamp is less than or equal to the current system time, it indicates that the instruction has expired and can be processed. The thread updates the zero-level head pointer from the current head node to its successor node through an atomic comparison and swap operation, thus achieving removal. After successful removal, the thread calculates the combined code using the unique business key and timestamp within the node, searches for and deletes the corresponding wake-up entry in the blocking wait mapping table, and then calls the state update processing subroutine to perform the actual state overwrite operation for the instruction.

[0156] Step S550: The state update processing task retrieves the header instruction from the state update processing queue, locates the target projection state machine instance based on the business unique key in the header instruction, and reads the current projection state and the most recent update timestamp recorded in the instance.

[0157] Once the state update processing task extracts a header instruction, its internally encapsulated business unique key is used as the primary index. The same query and matching process as in step S300 is executed in the hash table of the projection state machine instance set to accurately locate the target projection state machine instance. After successful location, the task reads the current projection state string from the instance's state storage area and the value of the most recent update timestamp from the most recent update timestamp area. These two values ​​are compared with the target state name identifier and delivery completion timestamp in the header instruction to determine whether to perform a state overwrite.

[0158] Step S560: Compare the abstract state node name identifier carried in the header instruction with the read current projection state. If they are completely identical and the timestamp of the header instruction is not greater than the most recent update timestamp, discard the header instruction and do not perform a state change. If they are not identical or the timestamp is updated, replace the current projection state of the target projection state machine instance with the name identifier and update the most recent update timestamp.

[0159] The state update processing task performs a byte-by-byte equality comparison between the abstract state node name identifier string in the header instruction and the current projection state string read in step S550. If they are completely identical, it further compares the delivery completion timestamp of the header instruction with the most recent update timestamp. If the timestamp is less than or equal to the most recent update timestamp, it indicates that an updated state change has occurred and been written to a later timestamp during the gap between message delivery and the queuing of state update instructions. The current instruction is a late duplicate update and should be discarded. The task directly releases the skip list node memory occupied by the instruction. If the name identifiers are different, or if the name identifiers are the same but the timestamp of the header instruction is greater than the most recent update timestamp, a state change is performed. The task overwrites the current projection state storage area of ​​the target projection state machine instance with the abstract state node name identifier carried in the header instruction, updates the most recent update timestamp to the delivery completion timestamp of the header instruction, and simultaneously calls the cache line refresh instruction to write the modified state storage area and timestamp area back to main memory, completing the state transition of the projection state machine instance.

[0160] In one embodiment, in step S500, when the comparison result is inconsistent, the message queue proxy layer blocks the delivery operation of the message to be delivered, and discards or dumps the message to be delivered to the audit queue. Specifically, this may include the following steps S570 to S5120: Step S570: The message queue broker layer reads the value of the processing policy indicator field in the message header of the message to be delivered. When the value of the processing policy indicator field matches the discard policy code, it calls the memory reclamation primitive to release the buffer memory block occupied by the complete message frame byte sequence of the message to be delivered, and destroys and reclaims the associated message processing context structure.

[0161] The processing policy indication field is an enumerated field within the fixed preamble or extension area of ​​the message header. It is filled in by the message producer during message construction according to business needs. Possible values ​​include the discard policy code and the dump audit policy code. Upon receiving a mismatch signal, the message processing logic reads the value of this field from the message header and compares it with a predefined discard policy code constant. If a match is found, the discard path is executed: the message processing logic calls a memory reclamation primitive to reclaim the memory block containing the complete message frame byte sequence into the memory pool. Specifically, the reclamation operation includes marking the memory block as free and inserting it into the corresponding size-level free memory block linked list. Then, it traverses the message processing context structure, destructs the dynamically allocated strings within it, and reclaims the off-stack memory occupied by the context structure itself, completing the complete release of memory resources.

[0162] Step S580: When the value of the processing policy indication field matches the dump audit policy code, open the audit queue storage file for the corresponding date. If the file does not exist, create a new file and write the audit file header marker. Obtain the current file end offset of the audit queue storage file as the starting position for this write.

[0163] The dump audit policy code is another predefined constant. When the value of the processing policy indicator field matches it, the message processing logic enters the dump path. The message processing logic calculates the corresponding date string based on the current system time, concatenates the file system root path and the date string to obtain the complete pathname of the audit queue storage file, and opens the file in append-only mode using the operating system's file opening interface. If the file does not exist, the operating system automatically creates a new file upon opening. When the message processing logic detects that the file length is zero, it first writes a fixed-content audit file header marker, which includes the file format version number and creation timestamp, to identify the file as an audit queue storage file. Then, it obtains the current end offset of the file through the file positioning interface and uses it as the starting position for writing this audit record.

[0164] Step S590: Generate a globally unique audit event identifier. The audit event identifier is formed by concatenating three parts: the nanosecond-level timestamp of the current moment, the worker node number of the message queue broker layer, and the node's local auto-incrementing counter value, to ensure the uniqueness of the identifier in a distributed deployment environment.

[0165] The message processing logic reads the nanosecond-level timestamp of the current moment from a high-precision clock source, formats it into a fixed-length hexadecimal or decimal string, reads the unique fixed-point integer number assigned to the worker node of this message queue broker layer within the cluster from the global configuration, and formats it into a string as well. Finally, it atomically retrieves an incrementing value from the thread-local or node-local auto-incrementing counter, increments the counter by one, and formats the counter value into a string as well. These three strings are concatenated together in the order of timestamp, worker node number, and auto-incrementing counter value to form an audit event identifier. This identifier is globally unique in a distributed deployment environment because the combination of the nanosecond timestamp and the auto-incrementing counter is unique within a single node, and the worker node number is globally unique within the cluster.

[0166] Step S5100: Extract the current projection state at the moment of blocking from the state storage area of ​​the target projection state machine instance as the pre-blocking state, extract the target state transition identifier from the message header of the message to be delivered as the blocked transition target state, and assemble the audit event identifier, business unique key, pre-blocking state, blocked transition target state and the original byte sequence length of the message to be delivered into an audit record.

[0167] The message processing logic uses the target projection state machine instance pointer located in step S300 or step S550 to read the current projection state string in its state storage area again, and uses this string as the pre-blocking state; at the same time, it reads the target state transition identifier string from the message processing context structure as the blocked transition target state. The audit record structure is constructed in memory, and its members sequentially include the audit event identifier string, the business unique key string, the pre-blocking state string, the blocked transition target state string, and the original byte sequence length value of the message to be delivered. Optionally, the audit record may also include a complete copy of the original byte sequence of the message to be delivered. The message processing logic fills these members into the audit record structure one by one.

[0168] Step S5110: Serialize the audit record into a byte stream in compact binary format, and write the byte stream starting from the offset at the end of the file in the audit queue storage file using the write-back method. After writing is completed, call the file system synchronization operation to force the data in the file system buffer to be flushed to the persistent storage medium.

[0169] The audit log structure needs to be serialized into a compact binary format for efficient storage and subsequent parsing. During serialization, each string field is written with a two-byte length prefix followed by the original string's byte content. The length value is written in network byte order, while integer fields are written in fixed-width network byte order. There are no padding bytes between fields. At the file end offset obtained in step S580, the message processing logic writes the serialized byte stream to the audit queue storage file via a file write system call. After the write operation returns, the message processing logic immediately performs a file system synchronization operation on the file descriptor. This synchronization operation triggers the operating system kernel to force-flush all dirty pages belonging to that file in the file system buffer to the physical sectors of the disk, ensuring that the audit logs are not lost even if a process exits abnormally or the server loses power.

[0170] Step S5120: After the audit record is successfully persisted, reply to the message producer with an abnormal state notification response. The abnormal state notification response carries the audit event identifier, the state before blocking, and the state of the blocked transition in the message body, so that the message producer knows the specific state context of the message being blocked.

[0171] An asynchronous response channel is maintained between the message queue broker layer and the message producer. Once the audit record is successfully written and persisted to disk, the message processing logic constructs an abnormal status notification response message. The message type field of this message is set to the type code corresponding to the abnormal status notification. The message body adopts a compact binary serialization format similar to the audit record, sequentially carrying the audit event identifier string, the pre-blocking state string, and the blocked transition target state string. The message processing logic sends this response message back through the corresponding response channel connected to the message producer. Upon receiving the abnormal status notification, the response processing module on the message producer side can parse out the audit event identifier, the pre-blocking state, and the blocked transition target state. This allows for accurate identification of a message being blocked due to an illegal state transition, and the module can then perform correlation and investigation with the operation and maintenance audit system based on the audit event identifier.

[0172] Figure 3 A hardware entity diagram of a computer system provided in an embodiment of the present invention, such as... Figure 3 As shown, the hardware entity of the computer system 1000 includes a processor 1001 and a memory 1002, wherein the memory 1002 stores a computer program that can run on the processor 1001, and the processor 1001 executes the program to implement the steps in the method of any of the above embodiments.

[0173] The memory 1002 stores computer programs that can run on the processor. The memory 1002 is configured to store instructions and applications that can be executed by the processor 1001. It can also cache data to be processed or already processed (e.g., image data, audio data, voice communication data, and video communication data) of the processor 1001 and various modules in the computer system 1000. It can be implemented by flash memory or random access memory (RAM).

[0174] When the processor 1001 executes the program, it implements any of the steps of the message queue load processing method applied to multi-service scenarios described above. The processor 1001 typically controls the overall operation of the computer system 1000.

[0175] The above description is merely an embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any changes or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in the present invention should be included within the scope of protection of the present invention.

Claims

1. A message queue load balancing method applied to multi-service scenarios, characterized in that, The method includes: In the message queue broker layer, a projection state machine instance is constructed that corresponds one-to-one with the business instance. The projection state machine instance records the current projection state of the corresponding business instance in the delivery business process. The current projection state is an abstract state node in the full lifecycle state chain from the creation of the delivery order to the completion of the delivery. The message queue broker layer receives a message to be delivered sent by the message producer, and reads the business unique key and the target state transition identifier from the message header of the message to be delivered. The business unique key is used to uniquely identify the business instance to which the message to be delivered belongs, and the target state transition identifier is used to indicate the next abstract state node of the business instance that the message to be delivered is expected to drive. Based on the read business unique key, a query and match is performed in the set of projection state machine instances maintained by the message queue broker layer to obtain the target projection state machine instance associated with the business unique key, and the current projection state of the business instance is extracted from the target projection state machine instance. The target state transition identifier is compared with the extracted current projected state input to a preset set of state transition rules to determine whether the transition from the current projected state to the abstract state node pointed to by the target state transition identifier conforms to the legal transition path defined in the preset set of state transition rules. When the comparison result is consistent, the message queue proxy layer sends the message to be delivered to the consumer instance and updates the current projection state of the target projection state machine instance to the abstract state node pointed to by the target state transition identifier. When the comparison result is inconsistent, the message queue proxy layer blocks the delivery operation of the message to be delivered and discards or dumps the message to be delivered to the audit queue.

2. The method according to claim 1, characterized in that, The message queue broker layer receives messages to be delivered from the message producer, and reads the business unique key and the target state transition identifier from the message header of the message to be delivered, including: In the memory pool of the message queue broker layer, a circular buffer is allocated for the message producer connection. The memory pages of the circular buffer are set to non-swapable. When the byte stream sent by the message producer arrives at the network card, the network card writes the byte stream into the free area pointed to by the tail pointer of the circular buffer through memory access operation, thus obtaining the original byte sequence of the message to be delivered. Starting from the head pointer position of the circular buffer, the original byte sequence is scanned, the occurrence position of the message frame separator mark in the original byte sequence is detected, the start offset address and end offset address of the message to be delivered are determined, and a complete message frame byte sequence is extracted from the circular buffer according to the start offset address and end offset address. Parse the fixed-length preamble of the complete message frame byte sequence, and read the total length field, protocol version field, and message header length field in sequence. Calculate the offset range of the message header portion in the complete message frame byte sequence using the value of the message header length field, and map consecutive bytes within the offset range to a set of message header fields. In the message header field set, the corresponding message header layout template is found by using the protocol version field as an index. The base address offset and segment length of the custom attribute segment in the message header field set are determined according to the message header layout template. The custom attribute segment byte sequence that matches the base address offset and segment length is cut out from the message header field set. Perform key-value pair decoding on the byte sequence of the custom attribute segment to parse out multiple sets of key-value pairs pre-filled by the message producer. Temporarily store the parsed sets of key-value pairs in a temporary key-value pair set. Each set of key-value pairs in the temporary key-value pair set consists of a key name string and a value segment byte string. In the temporary key-value pair set, key-value pairs whose key names are equal to the business unique key constant string are retrieved, the value area byte string of the key-value pair is read and converted into the business unique key string, key-value pairs whose key names are equal to the target state transition identifier constant string are retrieved, the value area byte string of the key-value pair is read and converted into the target state transition identifier string, and the two converted strings are encapsulated into the message processing context structure and passed to the subsequent processing stage.

3. The method according to claim 2, characterized in that, The key-value pair decoding of the custom attribute segment byte sequence, parsing out multiple sets of key-value pairs pre-filled by the message producer, includes: Read the integer value of the total number of key-value pairs from the first two bytes of the byte sequence of the custom attribute segment, and initialize an offset index array with a corresponding number of elements according to the total number of key-value pairs. The value of the first element of the offset index array points to the byte position immediately following the total number of key-value pairs. Starting from the starting offset of each key-value pair recorded in the offset index array, read a one-byte key name length identifier from the starting offset of the current key-value pair, take the integer value represented by the key name length identifier as the key name byte length, and offset the read pointer to the starting address of the key name byte string. Starting from the starting address of the key name byte string, read the number of bytes indicated by the length of the key name byte string continuously to obtain the original key name byte string. Check the character encoding mark byte of the original key name byte string and decode the original key name byte string into a key name string according to the encoding type indicated by the character encoding mark byte. After the end of the key name byte string, read two bytes of value area byte length identifier, parse the value area byte length identifier into the value area byte length, continue to read one byte of compression flag bit, and perform the value area byte string reading operation according to the value area byte length and compression flag bit; When the compression flag bit is set, the number of bytes indicated by the length of the value area byte read subsequently is used as the compressed value area byte string, and the compressed value area byte string is decompressed to recover the original value area byte string. When the compression flag bit is reset, the number of bytes indicated by the length of the value area byte read is used as the original value area byte string. The decoded key name string and the corresponding original value area byte string are combined to form a set of restored key-value pairs and stored in a temporary key-value pair set. If a key-value pair with the same key name string already exists in the temporary key-value pair set, the current restored key-value pair is used to overwrite the existing key-value pair until all sets of key-value pairs in the offset index array have been processed.

4. The method according to claim 3, characterized in that, The step of reading a one-byte key name length identifier from the starting offset of the current group of key-value pairs, using the integer value represented by the key name length identifier as the key name byte length, and offsetting the read pointer to the starting address of the key name byte string includes: Before accessing the starting offset of the current group key-value pair recorded in the offset index array, the current byte order mode of the central processing unit executing the method is detected. When the current byte order mode is little endian, all multi-byte values ​​subsequently read from the byte sequence of the custom attribute segment are byte-reversed and uniformly converted to big endian representation. Using the starting offset as the reference address, read one byte from the reference address, map the eight-bit binary value of the byte to an unsigned integer, assign the unsigned integer to the key name length identifier variable, and do not perform sign bit extension processing on the eight-bit binary value; Increment the value of the base address by 1 to obtain the starting address of the key name byte string. Determine whether the starting address of the key name byte string meets the word alignment access boundary requirements of the central processing unit. If it does not meet the requirements, the content of the key name byte string is obtained byte by byte by byte by byte by byte by single byte reading and then shifting and concatenating. Starting from the beginning address of the key name byte string, read the number of bytes equal to the value of the key name length identifier variable in sequence. Stor the bytes read each time in a character buffer on the thread stack. After all bytes have been read, write a string terminator to the end of the character buffer to obtain the complete key name byte string. The byte order mark that may exist at the beginning of the complete key name byte string is parsed. When the byte order mark is detected, the complete key name byte string is converted into a key name string by the character encoding and decoding scheme corresponding to the byte order mark. When the byte order mark is not detected, the preset default character encoding and decoding scheme is called for conversion. The converted key name string is used as the key name of the current group key-value pair, associated with the subsequently read value area byte string, and the group number of the offset index array is incremented. The key name length identifier is read for the next group key-value pair using the incremented group number, until the group number exceeds the total number of key-value pairs.

5. The method according to claim 1, characterized in that, The step of querying and matching the set of projection state machine instances maintained by the message queue broker layer based on the read business unique key to obtain the target projection state machine instance associated with the business unique key, and extracting the current projection state of the business instance from the target projection state machine instance, includes: Perform a bit-by-bit perturbation mixing operation on each character unit in the business unique key string to generate a hash bucket index value with a fixed bit width. Select a hash bucket as the target hash bucket from the hash table array of the projection state machine instance set using the hash bucket index value. Each hash bucket in the hash table array maintains a candidate projection state machine instance linked list. Acquire the bucket-level read lock of the target hash bucket, read the head pointer of the candidate projection state machine instance linked list within the interval holding the bucket-level read lock, start traversing along the linked list node pointed to by the head pointer, and perform a byte-by-byte binary full equality comparison between the instance business unique key field stored in each linked list node and the business unique key string. When the instance business unique key field of a certain linked list node is found to be completely consistent with the business unique key string during the traversal, the projection state machine instance pointed to by the linked list node is determined as the target projection state machine instance, and the traversal is stopped and the bucket-level read lock is released. When the last sentinel node of the candidate projection state machine instance linked list is still not matched, the miss state is recorded and the bucket-level read lock is released. Then, a free memory block with the same size as the projection state machine instance structure is requested from the memory allocator of the message queue agent layer. Write the length and content of the business unique key string into the index field area of ​​the free memory block, write the name identifier of the default starting abstract state node into the state storage area, write the current system time into the entry timestamp marker area, and write an empty identifier into the previous successfully executed state transition identifier area. Reacquire the bucket-level write lock of the target hash bucket, insert the linked list node corresponding to the initialized free memory block into the head of the candidate projection state machine instance linked list, perform a memory barrier operation, release the bucket-level write lock, and determine the projection state machine instance as the target projection state machine instance. Then, extract the current projection state from the state storage area of ​​the instance.

6. The method according to claim 5, characterized in that, The step of requesting a free memory block from the memory allocator of the message queue broker layer that is the same size as the projection state machine instance structure includes: Access the free memory block linked list maintained by the memory allocator of the message queue broker layer, check whether there is a node in the free memory block linked list whose size is greater than or equal to the size of the projection state machine instance structure, if it exists, remove the node from the linked list and return its address; If there is no node that meets the requirements in the free memory block list, a memory allocation request is sent to the operating system to obtain a new physical memory page. The physical memory page is then divided into multiple unit blocks of uniform size, each the size of a projected state machine instance structure. The extra unit blocks are then linked to the free memory block list for later use. The starting address of the obtained free memory block is aligned with the cache line size. If the starting address is not aligned to the cache line boundary, the address offset is adjusted so that the starting address of the actual memory area falls within the cache line alignment boundary. The adjusted memory block area is filled with zero values ​​byte by byte. The character sequence of the business unique key string is copied byte by byte to the specified offset of the index field area in the memory block. After the copy is completed, a string termination identifier is appended to the end. The name identifier constant string of the default starting abstract state node is copied to the state storage area in the same way, and the cache line refresh instruction is called to write the cache line where the state storage area is located back to the main memory to ensure visibility between multi-core processing units. Set the reference count of the projection state machine instance corresponding to the memory block to the initial active value, and forcibly convert the starting address of the memory block to the projection state machine instance pointer type, thus completing the conversion from the free memory block to the projection state machine instance.

7. The method according to claim 6, characterized in that, The steps of reacquiring the bucket-level write lock of the target hash bucket, inserting the linked list node corresponding to the initialized free memory block into the head of the candidate projection state machine instance linked list, and releasing the bucket-level write lock after performing a memory barrier operation include: Before attempting to acquire the bucket-level write lock, the business unique key field and the current projection state field inside the initialized projection state machine instance are filled to the final consistent state. Write merging optimization is then performed on the cache line containing the business unique key field and the current projection state field to eliminate fragmented write operations. Execute a write memory barrier instruction, which forces all pending write operation results in the current processing core's storage buffer to be propagated down to the shared cache level and finally to the main memory, in order to prevent subsequent pointer update operations from being detected by other processing cores before the data is completely written. After the write memory barrier instruction is executed, the bucket-level write lock of the target hash bucket is acquired, the current head pointer value of the candidate projection state machine instance linked list is read, and the successor pointer field of the linked list node to be inserted is assigned to the current head pointer value. The head pointer of the candidate projected state machine instance linked list is updated from the current head pointer value to the address of the linked list node to be inserted through an atomic comparison swap operation. If the atomic comparison swap operation fails because the head pointer is modified concurrently, the latest head pointer value is read again and the atomic comparison swap is tried again until it succeeds. After the atomic comparison swap operation returns successfully, a read memory barrier instruction is immediately executed. The read memory barrier instruction invalidates the prefetch queue of the current processing core, forcing subsequent linked list traversal operations to reload the head pointer and the content of the node it points to from main memory or shared cache. After the read memory barrier instruction is executed, the bucket-level write lock is released, and the insertion of the projection state machine instance into the candidate projection state machine instance linked list is completed.

8. The method according to claim 1, characterized in that, The step of comparing the target state transition identifier with the extracted current projected state input to a preset set of state transition rules, and determining whether the transition from the current projected state to the abstract state node pointed to by the target state transition identifier conforms to a legal transition path defined in the preset set of state transition rules, includes: Extract a list of directed edges starting from the current projection state from the set of state transition rules bound to the target projection state machine instance. Each directed edge in the list records the name identifier, transition type descriptor, and join flag of the endpoint abstract state node. Traverse the list of directed edges. For each directed edge in the list, perform a string equality comparison between the name identifier of the endpoint abstract state node recorded by the target state transition identifier and the name identifier of the abstract state node pointed to by the target state transition identifier, until a directed edge with an equal match is found and marked as a candidate directed edge. Read the set state of the linkage flag bit of the candidate directed edge. When the linkage flag bit is not set, skip the external state constraint verification process, generate a judgment signal that the comparison result is consistent, and output the transition type descriptor of the candidate directed edge as the transition type flag of this transition. When the joint query flag is set, the external business instance type identifier and the storage offset of the target external state constraint are extracted from the additional data area preset by the candidate directed edge, and the content of the target external state constraint is loaded in the additional storage area of ​​the target projection state machine instance according to the storage offset. Using the external business instance type identifier as a filtering condition, select an active instance set with the same business type from all currently alive projection state machine instances in the message queue broker layer, read the current projection state of each instance in the active instance set in turn, and perform an inclusion check between each read current projection state and the allowed state set defined in the target external state constraint condition. When the inclusion check result indicates that the current projection state of at least one active instance falls into the set of allowed states, a judgment signal indicating that the comparison result is consistent is generated; otherwise, a judgment signal indicating that the comparison result is inconsistent is generated, and the judgment signal, together with the transition type flag or the reason for the state mismatch, is transmitted to the message delivery decision stage.

9. The method according to claim 8, characterized in that, The step of performing an inclusion check between each currently projected state and the set of allowed states defined in the target external state constraints includes: The content of the target external state constraints is parsed, and a set of allowed states organized in list form is extracted. Each element in the set of allowed states is a name identifier string of an abstract state node. The total number of elements in the set of allowed states is calculated. Construct a set of bit positions for fast negation judgment for the set of allowed states, traverse the set of allowed states, perform a hash operation on the name identifier string of each abstract state node, map the hash result to a bit offset, and set the corresponding bit in the set of bit positions to a valid state. When it is necessary to perform an inclusion check on the current projection state string of an active instance, the same hash operation and mapping operation are first performed on the current projection state string, and the corresponding bit in the bit position set is checked to see if it is in a valid state. If it is in an invalid state, the result of non-inclusion is returned. If the corresponding bit in the set of bit positions is in a valid state, then the precise string comparison process is started, and the current projected state string is compared with each element in the set of allowed states one by one by byte. When the byte-by-byte equality comparison finds a completely identical match in the allowed state set, it returns a result containing the match and terminates the subsequent comparison. When no match is found after traversing all elements of the allowed state set, it returns a result not containing the match. The returned result, whether it includes or does not include, is taken as the final conclusion of the inclusion check and used to drive the generation of subsequent comparison and determination signals.

10. A computer system comprising a memory and a processor, the memory storing a computer program executable on the processor, characterized in that, When the processor executes the program, it implements the steps of the method according to any one of claims 1 to 9.