Serial number acquisition method, device and system
By using message queues in a distributed system to store sequence numbers and detect their quantity, the concurrent hot spots and performance issues of business servers obtaining sequence numbers in high-concurrency scenarios are resolved, and efficient sequence number acquisition is achieved.
Patent Information
- Application Number
- CN202110440981.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-04-23
- Publication Date
- 2025-09-12
- Estimated Expiration
- 2041-04-23
AI Technical Summary
In the high-concurrency scenario of distributed systems, existing technologies cannot effectively solve the concurrency hot spots and performance pressure problems of business servers when obtaining serial numbers, resulting in untimely serial number acquisition.
By detecting the number of sequence numbers in the message queue, if it is lower than the preset value, the sequence number is obtained from the database sequence number table and written to the message queue. The business server obtains the sequence number from the queue as a consumer and uses the message queue as intermediate storage to solve the hot spots and performance issues of high-concurrency sequence number acquisition.
It enables business servers to efficiently obtain serial numbers in distributed high-concurrency scenarios, solves concurrency hotspots and performance pressure, and ensures the uniqueness and timeliness of serial numbers.
Smart Images

Figure CN113127508B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of serial number generation, and in particular to a serial number acquisition method, device and system. Background Art
[0002] Serial numbers, such as bank account numbers and customer information numbers, are critical resources. Duplicates are not permitted, global uniqueness is guaranteed, and concurrency safety is essential in distributed systems. Currently, in high-concurrency scenarios, serial number retrieval based on a database serial number table creates concurrency hotspots and performance pressures when updating the database serial number table. This can lead to servers being unable to retrieve serial numbers in a timely and efficient manner. Therefore, the existing technology lacks a method that enables servers to efficiently retrieve serial numbers in distributed, high-concurrency scenarios. Summary of the Invention
[0003] In order to solve the technical problems in the above-mentioned background technology, the present invention proposes a method, device and system for obtaining a serial number.
[0004] To achieve the above object, according to one aspect of the present invention, a method for obtaining a sequence number is provided, the method comprising:
[0005] Detect the number of sequence numbers in the message queue;
[0006] If the number is lower than the first preset value, the sequence number is obtained from the database sequence number table and written into the message queue as the producer of the message queue, so that the business server obtains the sequence number from the message queue as the consumer of the message queue.
[0007] Optionally, if the number is lower than a first preset value, obtaining a sequence number from a database sequence number table and writing the obtained sequence number into the message queue as a producer of the message queue, specifically including:
[0008] If the number is lower than the first preset value, the serial number is obtained from the database serial number table and the obtained serial number is written into the message queue as the producer of the message queue until the number of serial numbers in the message queue reaches a second preset value.
[0009] Optionally, the serial number acquisition method further includes:
[0010] Upon receiving the sequence number acquisition request sent by the service server, the sequence number is acquired from the database sequence number table and sent to the service server, wherein the service server sends the sequence number acquisition request when the message queue is unavailable.
[0011] Optionally, the serial number acquisition method further includes:
[0012] The state of the sequence number written into the message queue in the database sequence number table is set to a first state, wherein the first state is used to indicate that the sequence number has been used.
[0013] Optionally, obtaining the serial number from the database serial number table specifically includes:
[0014] A sequence number in a second state is obtained from a sequence number table in a database, wherein the second state is used to indicate that the sequence number is unused.
[0015] In order to achieve the above object, according to another aspect of the present invention, a sequence number obtaining device is provided, the device comprising:
[0016] A sequence number detection module is used to detect the number of sequence numbers in the message queue;
[0017] The sequence number writing module is used to obtain the sequence number from the database sequence number table when the quantity is lower than the first preset value and write the obtained sequence number into the message queue as the producer of the message queue, so that the business server obtains the sequence number from the message queue as the consumer of the message queue.
[0018] Optionally, the serial number writing module is specifically used to obtain the serial number from the database serial number table when the number is lower than the first preset value and write the obtained serial number into the message queue as the producer of the message queue until the number of serial numbers in the message queue reaches a second preset value.
[0019] Optionally, the serial number obtaining device further includes:
[0020] The sequence number acquisition request processing module is used to obtain the sequence number from the database sequence number table and send the obtained sequence number to the business server when receiving the sequence number acquisition request sent by the business server, wherein the business server sends the sequence number acquisition request when the message queue is unavailable.
[0021] In order to achieve the above object, according to another aspect of the present invention, a sequence number acquisition system is provided, the system comprising: a sequence number server, a message queue and a service server;
[0022] The sequence number server is configured to detect the number of sequence numbers in the message queue, and when the number is lower than a first preset value, obtain a sequence number from a database sequence number table, and write the obtained sequence number into the message queue as a producer of the message queue;
[0023] The business server is used to serve as a consumer of the message queue and obtain a sequence number from the message queue.
[0024] Optionally, the sequence number server is specifically used to obtain the sequence number from the database sequence number table when the number is lower than the first preset value, and write the obtained sequence number into the message queue as the producer of the message queue until the number of sequence numbers in the message queue reaches a second preset value.
[0025] Optionally, the sequence number server is further used to obtain the sequence number from the database sequence number table and send the obtained sequence number to the business server when receiving the sequence number acquisition request sent by the business server, wherein the business server sends the sequence number acquisition request when the message queue is unavailable.
[0026] Optionally, the sequence number server is further used to set the status of the sequence number written into the message queue in the database sequence number table to a first status, wherein the first status is used to indicate that the sequence number has been used.
[0027] Optionally, the sequence number server obtains the sequence number from the database sequence number table, specifically including:
[0028] The sequence number server obtains a sequence number in a second state from a sequence number table in a database, wherein the second state is used to indicate that the sequence number is unused.
[0029] Optionally, there are multiple sequence number servers, and the multiple sequence number servers constitute a distributed sequence number cluster; there are multiple business servers, and the multiple business servers constitute a distributed business cluster.
[0030] In order to achieve the above-mentioned purpose, according to another aspect of the present invention, a computer device is further provided, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps in the above-mentioned serial number acquisition method when executing the computer program.
[0031] In order to achieve the above object, according to another aspect of the present invention, a computer-readable storage medium is further provided, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed in a computer processor, the steps in the above serial number acquisition method are implemented.
[0032] The beneficial effects of the present invention are as follows: the embodiment of the present invention stores the sequence number in the message queue and detects the number of sequence numbers in the message queue. If the number is lower than a first preset value, the sequence number is obtained from the database sequence number table and the obtained sequence number is written into the message queue as the producer of the message queue, while the business server obtains the sequence number from the message queue as the consumer of the message queue, thereby solving the hot spots and performance problems of obtaining sequence numbers in high concurrency, and achieving the beneficial effect of enabling the business server to efficiently obtain sequence numbers in a distributed high-concurrency scenario. BRIEF DESCRIPTION OF THE DRAWINGS
[0033] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative work. In the drawings:
[0034] Figure 1 This is a first flow chart of a method for obtaining a sequence number according to an embodiment of the present invention;
[0035] Figure 2 is a second flow chart of the method for obtaining a sequence number according to an embodiment of the present invention;
[0036] Figure 3 is a third flow chart of the method for obtaining a sequence number according to an embodiment of the present invention;
[0037] Figure 4 is a schematic diagram of a serial number acquisition system according to an embodiment of the present invention;
[0038] Figure 5 This is a structural block diagram of a serial number acquisition device according to an embodiment of the present invention;
[0039] Figure 6 Schematic diagram of a computer device according to an embodiment of the present invention. DETAILED DESCRIPTION
[0040] In order to enable those skilled in the art to better understand the solutions of the present invention, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the embodiments described are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts should fall within the scope of protection of the present invention.
[0041] It will be understood by those skilled in the art that embodiments of the present invention may be provided as methods, systems, or computer program products. Thus, the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware. Furthermore, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to magnetic disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0042] It should be noted that the terms "including" and "having" and any variations thereof in the specification and claims of the present invention and the above-mentioned drawings are intended to cover non-exclusive inclusions. For example, a process, method, system, product or apparatus comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or are inherent to these processes, methods, products or apparatuses.
[0043] It should be noted that, in the absence of conflict, the embodiments and features of the embodiments of the present invention can be combined with each other. The present invention will be described in detail below with reference to the accompanying drawings and in combination with the embodiments.
[0044] It should be noted that the serial number acquisition method, device and system of the present invention can be applied to the financial field as well as other technical fields.
[0045] In one aspect of the present invention, the present invention provides a serial number acquisition system, such as Figure 4 As shown, the sequence number acquisition system of the present invention includes: a sequence number server, a message queue and a business server.
[0046] The sequence number server is configured to detect the number of sequence numbers in the message queue, and when the number is lower than a first preset value, obtain a sequence number from a database sequence number table, and write the obtained sequence number into the message queue as a producer of the message queue;
[0047] The business server is used to serve as a consumer of the message queue and obtain a sequence number from the message queue.
[0048] In one embodiment of the present invention, the serial number of the present invention may be a bank account number, a customer information number, or the like, and the serial number of the present invention may be a continuous serial number or a non-continuous serial number.
[0049] In one embodiment of the present invention, there are multiple sequence number servers, and these multiple sequence number servers form a distributed sequence number cluster. In one embodiment of the present invention, these multiple sequence number servers can be located in different campuses. In one embodiment of the present invention, each sequence number server corresponds to a preset sequence number segment in the database sequence number table. When a sequence number server obtains a sequence number from the database sequence number table, it obtains the sequence number from the sequence number segment corresponding to the sequence number server.
[0050] In one embodiment of the present invention, there are multiple service servers, and the multiple service servers constitute a distributed service cluster.
[0051] In one embodiment of the present invention, the message queue may be any message queue in the prior art, such as a Kafka message queue.
[0052] In one embodiment of the present invention, the sequence number server is specifically used to obtain the sequence number from the database sequence number table when the number is lower than the first preset value, and write the obtained sequence number into the message queue as the producer of the message queue until the number of sequence numbers in the message queue reaches a second preset value.
[0053] In one embodiment of the present invention, the sequence number server is further used to obtain the sequence number from the database sequence number table and send the obtained sequence number to the business server when receiving the sequence number acquisition request sent by the business server, wherein the business server sends the sequence number acquisition request when the message queue is unavailable.
[0054] In one embodiment of the present invention, the sequence number server is further configured to set the state of the sequence number written into the message queue in the database sequence number table to a first state, wherein the first state is configured to indicate that the sequence number has been used.
[0055] In one embodiment of the present invention, the sequence number server obtains the sequence number from the database sequence number table. Specifically, the sequence number server obtains the sequence number in the second state from the database sequence number table, wherein the second state is used to indicate that the sequence number is not in use.
[0056] In one embodiment of the present invention, each sequence number server is provided with a sequence number generation component, which is used to obtain sequence numbers from the database sequence number table and add them to the message queue, and detect the depth of the message queue (i.e., detect the number of sequence numbers in the message queue) so as to replenish the sequence numbers in time.
[0057] In one embodiment of the present invention, a sequence number acquisition component is set in each business server, which is used to obtain the sequence number from the message queue and, when the message queue is unavailable, call the sequence number acquisition service provided by the sequence number cluster in a service degradation manner to obtain the sequence number (that is, directly send a sequence number acquisition request to the sequence number server to obtain the sequence number).
[0058] In one embodiment of the present invention, the operation process of the serial number generating component can be seen from the following steps S11 to S17.
[0059] Step S11: The serial number generating component is started.
[0060] Step S12: The sequence number generating component detects the sequence number queue depth in the message queue.
[0061] Step S13: Check whether the sequence number queue depth of the message queue exceeds a preset threshold. If so, jump to step S16; if not, jump to step S14.
[0062] Step S14: The sequence number generating component queries the database sequence number table to obtain the sequence number segment and updates the used sequence number value in the sequence number table.
[0063] Step S15: the sequence number generating component acts as a producer of the message queue and pushes each sequence number in the acquired sequence number end to the message queue one by one.
[0064] Step S16: The serial number generating component does not need to be supplemented with a serial number this time, and the current processing is skipped.
[0065] Step S17: Determine whether the sequence number generating component meets the thread termination condition. If so, terminate the thread; if not, jump to step S12.
[0066] In one embodiment of the present invention, the process of the serial number acquisition component can be seen from the following steps S21 to S25.
[0067] Step S21: The sequence number obtaining component receives a sequence number obtaining request.
[0068] Step S22: The sequence number obtaining component reads the sequence number in the message queue.
[0069] Step S23: Determine whether the sequence number is obtained from the message queue successfully. If successful, jump to step S25; if unsuccessful, jump to step S24.
[0070] Step S24: The message queue fails to obtain the sequence number, and the service is downgraded to obtain the sequence number by calling the sequence number cluster sequence number service.
[0071] Step S25: Return the serial number to obtain the result.
[0072] It can be seen that the present invention provides a sequence number acquisition system. The sequence number cluster of the present invention uses a sequence number generation component to obtain sequence number segments from the database sequence number table, and as a producer of the message queue, writes the obtained sequence numbers one by one into the message queue for storage; when each business cluster needs to use the sequence number, it uses the sequence number acquisition component as a consumer of the message queue to obtain the sequence number from the message queue, thereby solving the high concurrency sequence number acquisition hotspot and performance problems. The sequence number cluster background thread detects the depth of the message queue to determine whether the sequence number needs to be supplemented; when the message queue is unavailable, it downgrades to use the service call method to obtain the sequence number. The data storage mechanism based on the message queue of the present invention ensures that the message queue restart message is not lost, thereby solving the sequence number waste.
[0073] Based on the same inventive concept, the present invention also provides a method for obtaining a serial number, as described in the following embodiments. Since the principle of solving the problem by the method for obtaining a serial number is similar to that of the system for obtaining a serial number, the embodiments of the method for obtaining a serial number can refer to the embodiments of the system for obtaining a serial number, and the repeated parts will not be repeated.
[0074] Figure 1 This is the first flow chart of the serial number acquisition method according to an embodiment of the present invention, and the implementation subject is the serial number server in the serial number acquisition system of the above embodiment, such as Figure 1 As shown, in one embodiment of the present invention, the serial number acquisition method of the present invention includes step S101 and step S102.
[0075] Step S101: Detect the number of sequence numbers in the message queue.
[0076] Step S102: if the number is lower than a first preset value, obtain a sequence number from a database sequence number table and write the obtained sequence number into the message queue as a producer of the message queue, so that the business server obtains the sequence number from the message queue as a consumer of the message queue.
[0077] In one embodiment of the present invention, the above-mentioned step S102 can be specifically as follows: if the number is lower than the first preset value, the sequence number is obtained from the database sequence number table and the obtained sequence number is written into the message queue as the producer of the message queue until the number of sequence numbers in the message queue reaches a second preset value.
[0078] Figure 2 This is the second flow chart of the serial number acquisition method according to an embodiment of the present invention, and the implementation subject is the serial number server in the serial number acquisition system of the above embodiment, such as Figure 2 As shown, in one embodiment of the present invention, the serial number acquisition method of the present invention further includes step S201 and step S202.
[0079] Step S201: Receive a sequence number acquisition request sent by the service server.
[0080] Step S202: Obtain a sequence number from the database sequence number table and send the obtained sequence number to the business server, wherein the business server sends the sequence number acquisition request when the message queue is unavailable.
[0081] Figure 3 This is the second flow chart of the serial number acquisition method according to an embodiment of the present invention, and the implementation subject is the serial number server in the serial number acquisition system of the above embodiment, such as Figure 3 As shown, in one embodiment of the present invention, the serial number acquisition method of the present invention further includes step S301 and step S302.
[0082] Step S301: If the number is lower than the first preset value, obtain a sequence number with a second state from the database sequence number table, and write the obtained sequence number into the message queue as the producer of the message queue until the number of sequence numbers in the message queue reaches a second preset value, wherein the second state is used to indicate that the sequence number is not in use.
[0083] Step S302: setting the state of the sequence number written into the message queue in the database sequence number table to a first state, wherein the first state is used to indicate that the sequence number has been used.
[0084] As can be seen from the above embodiments, the sequence number cluster of the present invention uses a sequence number generation component to obtain sequence number segments from the database sequence number table, and as a producer of the message queue, writes the obtained sequence numbers one by one into the message queue for storage; when each business cluster needs to use the sequence number, it uses the sequence number acquisition component as a consumer of the message queue to obtain the sequence number from the message queue, thereby solving the high-concurrency sequence number acquisition hotspot and performance problems. The sequence number cluster background thread detects the depth of the message queue to determine whether the sequence number needs to be supplemented; when the message queue is unavailable, it downgrades to use the service call method to obtain the sequence number. The data storage mechanism based on the message queue ensures that the message queue restart message is not lost, thereby solving the problem of sequence number waste.
[0085] It should be noted that the steps shown in the flowcharts of the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions, and that, although a logical order is shown in the flowcharts, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0086] Based on the same inventive concept, an embodiment of the present invention further provides a sequence number acquisition device, which can be used to implement the sequence number acquisition method described in the above embodiment, as described in the following embodiment. Since the principle of solving the problem by the sequence number acquisition device is similar to that of the sequence number acquisition method, the embodiment of the sequence number acquisition device can refer to the embodiment of the sequence number acquisition method, and the repeated parts will not be repeated. As used below, the term "unit" or "module" can be a combination of software and / or hardware that implements a predetermined function. Although the device described in the following embodiments is preferably implemented in software, the implementation of hardware, or a combination of software and hardware, is also possible and conceived.
[0087] Figure 5 This is a structural block diagram of a serial number acquisition device according to an embodiment of the present invention. Figure 5 As shown, in one embodiment of the present invention, the serial number obtaining device of the present invention includes:
[0088] Sequence number detection module 1, used to detect the number of sequence numbers in the message queue;
[0089] The sequence number writing module 2 is used to obtain the sequence number from the database sequence number table when the number is lower than the first preset value and write the obtained sequence number into the message queue as the producer of the message queue, so that the business server obtains the sequence number from the message queue as the consumer of the message queue.
[0090] In one embodiment of the present invention, the serial number writing module 2 is specifically used to obtain the serial number from the database serial number table when the number is lower than the first preset value and write the obtained serial number into the message queue as the producer of the message queue until the number of serial numbers in the message queue reaches a second preset value.
[0091] In one embodiment of the present invention, the serial number obtaining device of the present invention further includes:
[0092] The sequence number acquisition request processing module is used to obtain the sequence number from the database sequence number table and send the obtained sequence number to the business server when receiving the sequence number acquisition request sent by the business server, wherein the business server sends the sequence number acquisition request when the message queue is unavailable.
[0093] In order to achieve the above object, according to another aspect of the present application, a computer device is also provided. Figure 6 As shown, the computer device includes a memory, a processor, a communication interface and a communication bus. The memory stores a computer program that can be run on the processor. When the processor executes the computer program, the steps in the above embodiment method are implemented.
[0094] The processor may be a central processing unit (CPU). The processor may also be other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, or a combination of the above chips.
[0095] Memory, as a non-transitory computer-readable storage medium, can be used to store non-transitory software programs, non-transitory computer-executable programs, and units, such as the corresponding program units in the above-described method embodiments of the present invention. The processor executes the non-transitory software programs, instructions, and modules stored in memory to perform various processor functions and work data processing, thereby implementing the methods in the above-described method embodiments.
[0096] The memory may include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function; the data storage area may store data created by the processor, etc. In addition, the memory may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other non-volatile solid-state storage device. In some embodiments, the memory may optionally include a memory remotely located relative to the processor, and these remote memories may be connected to the processor via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0097] The one or more units are stored in the memory, and when executed by the processor, perform the method in the above embodiment.
[0098] The specific details of the above-mentioned computer device can be understood by referring to the corresponding descriptions and effects in the above-mentioned embodiments, and will not be repeated here.
[0099] In order to achieve the above-mentioned purpose, according to another aspect of the present application, a computer-readable storage medium is further provided, wherein the computer-readable storage medium stores a computer program, and the computer program implements the steps in the above-mentioned serial number acquisition method when executed in a computer processor. Those skilled in the art will understand that the implementation of all or part of the process in the above-mentioned embodiment method can be completed by instructing the relevant hardware through a computer program, and the program can be stored in a computer-readable storage medium, and when the program is executed, it can include the process of the embodiment of each method as described above. Among them, the storage medium can be a magnetic disk, an optical disk, a read-only memory (ROM), a random access memory (RAM), a flash memory (Flash Memory), a hard disk drive (HDD) or a solid-state drive (SSD), etc.; the storage medium can also include a combination of the above-mentioned types of memory.
[0100] Obviously, those skilled in the art will appreciate that the modules or steps of the present invention described above can be implemented using a general-purpose computing device. They can be centralized on a single computing device or distributed across a network of multiple computing devices. Alternatively, they can be implemented using program code executable by a computing device, which can then be stored in a storage device and executed by the computing device. Alternatively, they can be fabricated into separate integrated circuit modules, or multiple modules or steps can be fabricated into a single integrated circuit module for implementation. Thus, the present invention is not limited to any specific combination of hardware and software.
[0101] The foregoing description is merely a preferred embodiment of the present invention and is not intended to limit the present invention. Those skilled in the art will readily appreciate that various modifications and variations of the present invention are possible. Any modifications, equivalent substitutions, or improvements made within the spirit and principles of the present invention are intended to be within the scope of protection of the present invention.
Claims
1. A method for obtaining a sequence number, characterized in that: Applied to a sequence number server, where there are multiple sequence number servers, the multiple sequence number servers constitute a distributed sequence number cluster, and the multiple sequence number servers are arranged in different parks, the method includes: Detect the number of sequence numbers in the message queue; If the number is lower than the first preset value, a sequence number in the second state is obtained from the database sequence number table and the obtained sequence number is written into the message queue as the producer of the message queue until the number of sequence numbers in the message queue reaches the second preset value, so that the business server obtains the sequence number from the message queue as a consumer of the message queue, and sets the state of the sequence number written into the message queue to the first state in the database sequence number table, wherein the first state is used to indicate that the sequence number has been used, and the second state is used to indicate that the sequence number is not used; in the database sequence number table, each sequence number server corresponds to a preset sequence number segment, and when the sequence number server obtains the sequence number from the database sequence number table, it obtains the sequence number from the sequence number segment corresponding to the sequence number server; there are multiple business servers, and the multiple business servers constitute a distributed business cluster; the message queue is a Kafka message queue; Upon receiving the sequence number acquisition request sent by the service server, the sequence number is acquired from the database sequence number table and sent to the service server, wherein the service server sends the sequence number acquisition request when the message queue is unavailable.
2. A serial number acquisition device, characterized in that: Applied to a sequence number server, where there are multiple sequence number servers, the multiple sequence number servers constitute a distributed sequence number cluster, and the multiple sequence number servers are arranged in different parks. The device includes: A sequence number detection module is used to detect the number of sequence numbers in the message queue; A sequence number writing module is used to obtain a sequence number in the second state from the database sequence number table when the number is lower than the first preset value and write the obtained sequence number into the message queue as the producer of the message queue until the number of sequence numbers in the message queue reaches the second preset value, so that the business server obtains the sequence number from the message queue as the consumer of the message queue, and sets the state of the sequence number written into the message queue to the first state in the database sequence number table, wherein the first state is used to indicate that the sequence number has been used, and the second state is used to indicate that the sequence number is not used; in the database sequence number table, each sequence number server corresponds to a preset sequence number segment, and when the sequence number server obtains the sequence number from the database sequence number table, it obtains the sequence number from the sequence number segment corresponding to the sequence number server; there are multiple business servers, and the multiple business servers constitute a distributed business cluster; the message queue is a Kafka message queue; The sequence number acquisition request processing module is used to obtain the sequence number from the database sequence number table and send the obtained sequence number to the business server when receiving the sequence number acquisition request sent by the business server, wherein the business server sends the sequence number acquisition request when the message queue is unavailable.
3. A serial number acquisition system, characterized in that: include: A sequence number server, a message queue, and a business server; the sequence number servers are multiple, the multiple sequence number servers constitute a distributed sequence number cluster, and the multiple sequence number servers are set in different parks; the message queue is a Kafka message queue; the business servers are multiple, and the multiple business servers constitute a distributed business cluster; The sequence number server is used to detect the number of sequence numbers in the message queue, and when the number is lower than a first preset value, obtain a sequence number in a second state from a database sequence number table, and write the obtained sequence number into the message queue as a producer of the message queue until the number of sequence numbers in the message queue reaches a second preset value, and set the state of the sequence number written into the message queue to the first state in the database sequence number table, wherein the first state is used to indicate that the sequence number has been used, and the second state is used to indicate that the sequence number is not used; in the database sequence number table, each sequence number server corresponds to a preset sequence number segment, and when the sequence number server obtains the sequence number from the database sequence number table, it obtains the sequence number from the sequence number segment corresponding to the sequence number server; The business server is used to serve as a consumer of the message queue and obtain a sequence number from the message queue; The sequence number server is further configured to obtain a sequence number from the database sequence number table and send the obtained sequence number to the business server upon receiving a sequence number acquisition request sent by the business server, wherein the business server sends the sequence number acquisition request when the message queue is unavailable.
4. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the computer program, the method according to claim 1 is implemented.
5. A computer-readable storage medium storing a computer program, characterized in that: The computer program implements the method according to claim 1 when executed in a computer processor.
Citation Information
Patent Citations
Serial number acquisition method, device and system, electronic equipment and storage medium
CN110515956A