CN117633044A - Data calling method and device, electronic equipment and computer readable storage medium - Google Patents

Data calling method and device, electronic equipment and computer readable storage medium Download PDF

Info

Publication number
CN117633044A
CN117633044A CN202210948925.3A CN202210948925A CN117633044A CN 117633044 A CN117633044 A CN 117633044A CN 202210948925 A CN202210948925 A CN 202210948925A CN 117633044 A CN117633044 A CN 117633044A
Authority
CN
China
Prior art keywords
consumed
message
current message
consumption
delay
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202210948925.3A
Other languages
Chinese (zh)
Inventor
尚楷
赵国庆
杜晓宇
曾琳铖曦
吴海英
蒋宁
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Mashang Xiaofei Finance Co Ltd
Original Assignee
Mashang Xiaofei Finance Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Mashang Xiaofei Finance Co Ltd filed Critical Mashang Xiaofei Finance Co Ltd
Priority to CN202210948925.3A priority Critical patent/CN117633044A/en
Publication of CN117633044A publication Critical patent/CN117633044A/en
Pending legal-status Critical Current

Links

Landscapes

  • Telephonic Communication Services (AREA)

Abstract

The disclosure provides a data calling method and device, electronic equipment and a computer readable storage medium, and belongs to the technical field of computers. The method comprises the following steps: receiving a current message to be consumed; judging whether the current message to be consumed meets the consumption condition or not; under the condition that the current message to be consumed does not meet the consumption condition, the current message to be consumed is sent to a delay message queue; the delay message queue is arranged in a storage space outside the consumption end; executing the judgment again to judge whether the current message to be consumed meets the consumption condition or not under the condition that the time of the current message to be consumed in the delay message queue reaches the delay time; and consuming the current message to be consumed under the condition that the current message to be consumed meets the consumption condition. According to the embodiment of the disclosure, parallel consumption is supported, design logic is simplified, and the efficiency of data calling is improved.

Description

Data calling method and device, electronic equipment and computer readable storage medium
Technical Field
The disclosure relates to the technical field of computers, and in particular relates to a data calling method and device, electronic equipment and a computer readable storage medium.
Background
As business of corporate users increases, applications are more and more, call relations among different applications are more and more complex, and complexity and the number of applications are even exponentially increased. For any one application, there is inevitably a data call with one or more other applications, such as a message generated by a first application calling a second application. In some specific scenarios, there is a certain order relationship for data calls between different applications.
The distributed message system and the cache database can be used for realizing data call among different applications, however, the two data call modes have the defects of complex realization process, low call efficiency and the like in different degrees.
Disclosure of Invention
The disclosure provides a data calling method and device, electronic equipment and a computer readable storage medium.
In a first aspect, the present disclosure provides a data calling method, the method comprising: receiving a current message to be consumed;
judging whether the current message to be consumed meets the consumption condition or not;
transmitting the current message to be consumed to a delay message queue under the condition that the current message to be consumed does not meet the consumption condition; the delay message queue is arranged in a storage space outside the consumption end;
Executing the judgment again if the current message to be consumed meets the consumption condition under the condition that the time of the current message to be consumed in the delay message queue reaches the delay time;
and consuming the current message to be consumed under the condition that the current message to be consumed meets the consumption condition.
In a second aspect, the present disclosure provides a data calling apparatus, including:
the receiving module is used for receiving the current message to be consumed;
the first judging module is used for judging whether the current message to be consumed meets the consumption condition or not;
the sending module is used for sending the current message to be consumed to a delay message queue under the condition that the current message to be consumed does not meet the consumption condition; the delay message queue is arranged in a storage space outside the consumption end;
the first judging module is further configured to execute the judging whether the current message to be consumed meets a consumption condition again when the time of the current message to be consumed in the delay message queue reaches a delay time;
and the consumption module is used for consuming the current message to be consumed under the condition that the current message to be consumed meets the consumption condition.
In a third aspect, the present disclosure provides an electronic device comprising: at least one processor; and a memory communicatively coupled to the at least one processor; wherein the memory stores one or more computer programs executable by the at least one processor, one or more of the computer programs being executable by the at least one processor to enable the at least one processor to perform the data call method described above.
In a fourth aspect, the present disclosure provides a computer readable storage medium having stored thereon a computer program, wherein the computer program when executed by a processor/processing core implements the data calling method described above.
According to the embodiment provided by the disclosure, when the current message to be consumed does not meet the consumption condition, the current message to be consumed is cached to the delay message queue, so that service decoupling is realized, after the current message to be consumed reaches the preset delay time, whether the consumption condition is met is judged again, if the current message to be consumed meets the consumption condition, the current message to be consumed is consumed, and because the delay message queue is arranged in a storage space outside the consumption end, the accumulation of the current message to be consumed at the consumption end is avoided, the occupation of storage resources of the consumption end is reduced, and the performance bottleneck of a database at the consumption end is relieved; the design logic is simple, a background program is not required to be arranged at the consumption end, the complexity and difficulty of the design of the consumption end are not increased, the consumption end can process a plurality of messages to be consumed in parallel from the delay message queue, and the processing efficiency is improved.
Drawings
The accompanying drawings are included to provide a further understanding of the disclosure, and are incorporated in and constitute a part of this specification, illustrate embodiments of the disclosure and together with the description serve to explain the disclosure, without limitation to the disclosure. The above and other features and advantages will become more readily apparent to those skilled in the art by describing in detail exemplary embodiments with reference to the attached drawings, in which:
FIG. 1 is an application scenario diagram of a data call according to an embodiment of the present disclosure;
FIG. 2 is a flowchart of a data calling method provided in an embodiment of the present disclosure;
FIG. 3 is a flowchart of step S203 in an embodiment of the present disclosure;
FIG. 4 is a flowchart of another data calling method provided by an embodiment of the present disclosure;
FIG. 5 is a block diagram of a data calling device provided by an embodiment of the present disclosure;
fig. 6 is a block diagram of an electronic device according to an embodiment of the present disclosure.
Detailed Description
For a better understanding of the technical solutions of the present disclosure, exemplary embodiments of the present disclosure will be described below with reference to the accompanying drawings, in which various details of the embodiments of the present disclosure are included to facilitate understanding, and they should be considered as merely exemplary. Accordingly, one of ordinary skill in the art will recognize that various changes and modifications of the embodiments described herein can be made without departing from the scope and spirit of the present disclosure. Also, descriptions of well-known functions and constructions are omitted in the following description for clarity and conciseness.
Embodiments of the disclosure and features of embodiments may be combined with each other without conflict.
As used herein, the term "and/or" includes any and all combinations of one or more of the associated listed items.
The terminology used herein is for the purpose of describing particular embodiments only and is not intended to be limiting of the disclosure. As used herein, the singular forms "a," "an," and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise. It will be further understood that the terms "comprises" and/or "comprising," when used in this specification, specify the presence of stated features, integers, steps, operations, elements, and/or components, but do not preclude the presence or addition of one or more other features, integers, steps, operations, elements, components, and/or groups thereof. The terms "connected" or "connected," and the like, are not limited to physical or mechanical connections, but may include electrical connections, whether direct or indirect.
Unless otherwise defined, all terms (including technical and scientific terms) used herein have the same meaning as commonly understood by one of ordinary skill in the art. It will be further understood that terms, such as those defined in commonly used dictionaries, should be interpreted as having a meaning that is consistent with their meaning in the context of the relevant art and the present disclosure, and will not be interpreted in an idealized or overly formal sense unless expressly so defined herein.
In some application scenarios, the distributed messaging system may be used to implement service invocation between different applications, for example, a first application (e.g., a producer application) generates a first message P-a and a second message P-B, and a second application (e.g., a consumer application) consumes the first message P-a and the second message P-B, where the first message P-a and the second message P-B have service dependencies, and where the second application consumes the first message P-a and the second message P-B, the interval between the first message P-a and the second message P-B does not affect the final consumption result of the second application, but must do so in the order of consuming the first message P-a and then consuming the second message P-B.
The distributed message system may implement a function of sequentially delivering messages based on a single partition of the message queue, that is, the first application generates the first message P-a and the second message P-B and sends the first message P-a and the second message P-B to the distributed message system in order, and the distributed message system sequentially pushes the first message P-a and the second message P-B to the second application, or the second application sequentially pulls the first message P-a and the second message P-B from the distributed message system, so that the second application sequentially consumes the first message P-a and the second message P-B in a serial manner.
However, since the second application calls the first message P-a and the second message P-B in a serial manner, not only the call efficiency is low; moreover, the first message P-a and the second message P-B must be pushed to the second application in the order of consumption, otherwise message backlog, traffic suspension, and even data loss are easily caused. If the second application calls the message P-a and the second message P-B in a parallel manner, design complexity and difficulty of the second application are increased.
The database caching mode is to cache the first message P-A and the second message P-B in the database and consume the messages meeting the conditions at regular time. For example, after the second application receives the first message P-a, the first message P-a is cached; when the second message P-B is received, it is first queried whether the first message P-A exists in the database. If the first message P-A exists in the database, directly consuming the second message P-B; if the first message P-A does not exist in the database, the second message P-B is cached. And periodically consuming the buffered second messages P-B by a preset background program. After a preset period of time, the second message P-B may be discarded without meeting the consumption condition.
Under the condition that the data volume of the second message P-B is large, the database caches the second message P-B to form a bottleneck; moreover, caching the second message P-B in the database severely reduces the consumption efficiency when the second message P-B data is very much data that does not need to be consumed. In addition, in order to consume the cached second message P-B, the background program needs to be started, and the background program occupies application resources, if the production time of the first message P-a is delayed from that of the second message P-B (in extreme cases), the application resources occupied by the background program may be even higher than those required for normally consuming the second message P-B.
Based on the above-mentioned problems in the related art, the embodiments of the present disclosure provide a data calling method, which mainly aims at the calling of each application in the system development process or the calling of each application when using the system, and the calling of these applications has very strong logic, that is, the calling of the subsequent application must be performed on the premise that the previous application is called, so that the traffic faults such as message backlog, data loss, etc. can be avoided, and no additional background program is required to control the message queue.
The data calling method provided by the embodiment of the disclosure may be executed by electronic devices such as a terminal device or a server, where the terminal device may be a vehicle-mounted device, a User Equipment (UE), a mobile device, a User terminal, a cellular phone, a cordless phone, a personal digital assistant (Personal Digital Assistant, PDA), a handheld device, a computing device, a vehicle-mounted device, a wearable device, etc., and the server may be an independent physical server, a server cluster or a distributed system formed by a plurality of physical servers, or a cloud server that provides cloud computing services. The method may be embodied by a processor invoking computer readable program instructions stored in a memory.
Fig. 1 is an application scenario diagram of a data call according to an embodiment of the present disclosure. Referring to fig. 1, a producer 11 generates a message to be consumed, a consumer 12 consumes the message to be consumed, and a delay message queue 13 or a pending message queue 14 can buffer the message to be consumed, wherein the message to be consumed buffered in the delay message queue 13 can be mobilized again, and the message to be consumed buffered in the pending message queue 14 requires manual intervention.
In some application scenarios, the production side 11 includes one or more production side applications, such as production side applications A, B, … … i, … … N, each of which can generate one or more messages to be consumed, such as each of which can generate one message to be consumed, denoted P-A, P-B, … … P-i, P-N, respectively, where N is an integer and greater than 2. The consumer 12 may include one or more consumer applications, such as consumer applications C1, C2, … …, cj, … … CM, the order in which the consumer applications consume messages to be consumed is represented by a call chain, i.e., the call chain is arranged in the order in which the messages to be consumed are consumed at the consumer. For example, the call chain for each consumer application can be written as:
[C1-P-A,C1-P-B,...,C1-P-i,...,C1-P-N],
[C2-P-A,C2-P-B,...,C2-P-i,...,C2-P-N],
……
[Cj-P-A,Cj-P-B,...,Cj-P-i,...,Cj-P-N],
……
[CM-P-A,CM-P-B,...,CM-P-i,...,CM-P-N],
wherein N, M is an integer greater than 2, i [ A, N ], j [1, M ].
In the embodiment of the disclosure, the message to be consumed may be directly consumed by the consumer, and when the consumption condition is not met, the message to be consumed may be buffered in the delay message queue 13 or the pending message queue 14, where the delay message queue 13 may be disposed in a device of the producer or a third party that may buffer data, and the pending message queue 14 is typically disposed in a device of the third party that buffers data.
For convenience of description, the production-side application is abbreviated as production-side and the consumption-side application is abbreviated as consumption-side in the embodiments of the present disclosure.
Fig. 2 is a flowchart of a data calling method according to an embodiment of the present disclosure. Referring to fig. 1 and 2, the method includes:
step S201, a current message to be consumed is received.
The current message to be consumed is a message to be consumed received by a consumer, and the message to be consumed is a message generated by a producer.
Step S202, judging whether the current message to be consumed meets the consumption condition.
The consumption condition is a basis for judging whether the current message to be consumed can be consumed or not. In embodiments of the present disclosure, one consumption condition may be set for each message to be consumed.
Illustratively, the call chain includes a message to be consumed P-A, a message to be consumed P-B, and a message to be consumed P-C in order, the message to be consumed P-B being consumed on the condition that the message to be consumed P-A has been consumed, and the message to be consumed P-C being consumed on the condition that the message to be consumed P-B has been consumed. When the current message to be consumed received by the consumer is the message P-B to be consumed, if the message P-A to be consumed is already consumed, the message P-B to be consumed meets the consumption condition. If the message P-A to be consumed is not consumed, the message P-B to be consumed does not meet the consumption condition. Similarly, when the current message to be consumed received by the consuming end is the message to be consumed P-C, if the message to be consumed P-A is already consumed but the message to be consumed P-B is not consumed, the message to be consumed P-C does not meet the consumption condition; if the message to be consumed P-A has been consumed, but the message to be consumed P-B is also consumed, the message to be consumed P-C satisfies the consumption condition.
In some embodiments, the consumption condition may be determined based on an attribute of the message to be consumed.
The attributes of the message to be consumed comprise a ordering message, a payment message, a stock message, a delivery message, a logistics message and the like, and consumption conditions corresponding to different attributes are different. For example, the consumption condition corresponding to the payment message is that the order message is consumed, and the consumption condition corresponding to the stock message may be that both the order message and the payment message are consumed.
In the implementation of the present disclosure, since the consumption condition is determined based on the attribute of the message to be consumed, the consumption end can process the message to be consumed meeting the consumption condition in parallel, thereby improving the consumption efficiency.
In some embodiments, the consumption condition includes that a message to be consumed arranged in the call chain before the current message to be consumed has been consumed.
The arrangement sequence of the messages to be consumed in the call chain is determined based on the attribute of the messages to be consumed. In some embodiments, the call chain is arranged in the order in which messages to be consumed are consumed by the consumer. The previous message to be consumed in the call chain is consumed as the consumption condition of the next message to be consumed. To facilitate determining the call chain, the call chain may be determined by the message weight to be consumed. If the weight of the message to be consumed is higher, the ordering of the message to be consumed in the call chain is more advanced.
Step S203, in the case that the current message to be consumed does not meet the consumption condition, the current message to be consumed is sent to a delay message queue.
The delay message queue is arranged in a storage space outside the consumption end, namely, the delay message queue does not occupy storage and cache resources of the consumption end, so that the demand on the consumption end resources is reduced. In some embodiments, the delayed message queue may buffer messages to be consumed, which may be provided in the producer or in a device of a third party that may buffer data.
In some embodiments, the third party's device may be a distributed messaging system. The distributed message system can realize decoupling of the current message to be consumed, the message call between the production end and the consumption end is converted into call between the production end and the distributed message system and call between the consumption end and the distributed message system, so that the complexity of call is reduced, but for the message to be consumed with a sequence, the complexity is still higher, and the delay message queue can realize the multiple delay function of the message to be consumed, so that the architecture of data call is further simplified.
Step S204, in the case that the current message to be consumed reaches the delay time in the delay message queue, the judgment is executed again to judge whether the current message to be consumed meets the consumption condition.
In step S204, it is determined whether the time of the current message to be consumed in the delay message queue reaches the delay time, and when the time of the current message to be consumed in the delay message queue reaches the delay time, the process returns to step S202 again.
In the embodiment of the disclosure, the delay time may be preset according to the consumption time of the message to be consumed in the call chain.
In some embodiments, the delay time is determined in accordance with the consumption time required for a message to be consumed that is arranged before the current message to be consumed in the call chain; the call chains are arranged according to the consumption order of the messages to be consumed at the consumption end.
For example, the consuming end C consumes according to the order of the messages to be consumed P-A, P-B, P-D, P-E, the call chain is marked as [ C-P-A, C-P-B, C-P-D, C-P-E ], the consuming time of the messages to be consumed P-A, P-B, P-D, P-E is respectively E (a), E (B), E (d) and E (E), and if the order of the messages to be consumed received by the consuming end is C-P-A, C-P-E, C-P-D, C-P-B. When the current message to be consumed is the message to be consumed P-B, only the message to be consumed P-A is arranged in front in the call chain, and the delay time of the message to be consumed P-B is determined based on the consumption time of the message to be consumed P-A.
When the current message to be consumed is the message to be consumed P-D, the message to be consumed P-A, P-B in the call chain is arranged in front, and the delay time of the message to be consumed P-D is determined based on the consumption time of the message to be consumed P-A and the message to be consumed P-B.
When the current message to be consumed is the message to be consumed P-E, the message to be consumed P-A, P-B, P-D is arranged in the front in the call chain, and the delay time of the message to be consumed P-E is determined based on the consumption time of the message to be consumed P-A, P-B, P-D. Wherein the consumption time refers to the time it takes to execute the message to be consumed.
In some embodiments, the delay time is greater than or equal to the sum of consumption times required for messages to be consumed that are arranged in the call chain before the current message to be consumed.
For example, the consuming end C consumes according to the order of the messages to be consumed P-A, P-B, P-D, P-E, the call chain is marked as [ C-P-A, C-P-B, C-P-D, C-P-E ], the consuming time of the messages to be consumed P-A, P-B, P-D, P-E is respectively E (a), E (B), E (d) and E (E), and if the order of the messages to be consumed received by the consuming end is C-P-A, C-P-E, C-P-D, C-P-B. When the current message to be consumed is the message to be consumed P-B, the delay time of the message to be consumed P-B may be set to d (B) > =e (a). When the current message to be consumed is the message to be consumed P-D, the delay time of the message to be consumed P-D may be set to D (D) > =d (b) +e (b). When the current message to be consumed is the message to be consumed P-E, the delay time of the message to be consumed P-E may be set to d (E) > =d (d) +e (d).
In some embodiments, the current message to be consumed is bound to the corresponding delay time when it is sent to the delay message queue.
In step S205, the current message to be consumed is consumed if the current message to be consumed satisfies the consumption condition.
For example, the consuming end C consumes the messages P-A, P-B in order, the call chain is denoted by [ C-P-A, C-P-B ], and when the consuming end C receives the message P-B to be consumed, if the message P-a to be consumed has already been consumed, the message P-B to be consumed satisfies the consumption condition, and then the message P-B to be consumed is consumed by the consuming end C.
According to the embodiment provided by the disclosure, when the current message to be consumed does not meet the consumption condition, the current message to be consumed is cached to the delay message queue, service decoupling is realized, after the current message to be consumed reaches the preset delay time, whether the consumption condition is met is judged again, if the current message to be consumed meets the consumption condition, the current message to be consumed is consumed, and because the delay message queue is arranged in a storage space outside the consumption end, the current message to be consumed is not accumulated at the consumption end, so that the occupation of the consumption end resource is reduced, and the performance bottleneck of the consumption end database is relieved; the design logic is simple, a background program is not required to be arranged at the consumption end, the complexity and difficulty of the design of the consumption end are not increased, parallel calling can be supported, and the processing efficiency is improved.
In some embodiments, step S204, before sending the current message to be consumed to the delay message queue, further includes:
judging whether the waiting time of the current message to be consumed reaches the preset maximum waiting time or not; and sending the current message to be consumed to a pending message queue under the condition that the waiting time of the current message to be consumed reaches the maximum waiting time.
Wherein the waiting time of the current waiting message is the total waiting time of the current waiting message in the delay message queue. The pending message queue may be located in a device of a third party or at the consumer end.
For example, the message to be consumed P-D is delayed twice in the delay message queue, each time by a delay time D (D), and the waiting time of the message to be consumed P-D is 2×d (D).
The maximum waiting time is the longest waiting time set for the current message to be consumed, and if the current message to be consumed does not reach the maximum waiting time, the current message to be consumed is cached to a delay message queue; and when the current message to be consumed is greater than or equal to the maximum waiting time, caching the current message to be consumed into a pending message queue.
In the embodiment of the disclosure, the maximum waiting time is utilized to judge whether the message to be consumed enters the delay message queue, only the message to be consumed with the waiting time smaller than the maximum waiting time enters the delay queue, and the message to be consumed with the waiting time larger than or equal to the maximum waiting time enters the undetermined message queue, and does not enter the delay message queue any more, so that the data volume of the delay message queue can be reduced, and the message to be consumed is prevented from occupying the delay message queue resource due to the fact that the message to be consumed is continuously and circularly waiting in the delay message queue, thereby improving the management efficiency of the delay message queue.
In some embodiments, the maximum latency is determined from the delay time required for a message to be consumed that is ordered before the current message to be consumed in the call chain.
The delay time is determined according to the consumption time required by the message to be consumed arranged before the current message to be consumed in the call chain, and the call chain is arranged according to the consumption sequence of the message to be consumed. The determination of the delay time is described above, and is not described herein.
In some embodiments, the maximum waiting time of the first message to be consumed needing delay in the call chain is k times of the delay time of the message to be consumed; wherein k is a number greater than 1; the maximum waiting time of the messages to be consumed except the first message to be consumed needing to be delayed in the call chain is larger than or equal to the sum of the delay time of the messages to be consumed and the maximum waiting time of the previous messages to be consumed.
For example, the consuming end C consumes according to the order of the messages to be consumed P-A, P-B, P-D, P-E, the call chain is marked as [ C-P-A, C-P-B, C-P-D, C-P-E ], the consuming time of the messages to be consumed P-A, P-B, P-D, P-E is respectively E (a), E (B), E (d) and E (E), and if the order of the messages to be consumed received by the consuming end is C-P-A, C-P-E, C-P-D, C-P-B. When the current message to be consumed received by the consumer C is the message P-A to be consumed, the message P-A to be consumed is directly consumed by the consumer C without delay. When the consumer side C receives the message P-B to be consumed, since the message P-a to be consumed is not yet consumed, the message P-B to be consumed needs to be delayed, and the message P-B to be consumed is used as the first message to be consumed needing to be delayed in the call chain, where the maximum waiting time maxwaittme of the message P-B to be consumed is greater than or equal to kxd (B), that is, mw (B) is greater than or equal to kxd (B), where mw (B) is the maximum waiting time of the message P-B to be consumed, d (B) is the delay time of the message P-B to be consumed, and k is a value greater than 1, such as k is 3, 3.5 or 5.
When the current message to be consumed received by the consumer C is the message to be consumed P-D, since the messages to be consumed P-a and P-B are not yet consumed, the message to be consumed P-D needs to be delayed, but the message to be consumed P-D is not the first message to be consumed requiring delay in the call chain, so that the maximum waiting time mw (D) of the message to be consumed P-D is determined by the maximum waiting time mw (B) of the message to be consumed P-B and the delay time of the message to be consumed P-D, for example, the maximum waiting time mw (D) of the message to be consumed P-D is greater than or equal to the sum of the maximum waiting time mw (B) of the message to be consumed P-B and the delay time D (D) of the message to be consumed P-D, that is, mw (D) > mw (B) +d (D), where mw (D) is the maximum waiting time mw (B) of the message to be consumed P-D and mw (D) is the delay time of the message to be consumed P-D.
When the current message to be consumed received by the consumer C is the message to be consumed P-E, since the messages to be consumed P-A, P-B and P-D are not yet consumed, the message to be consumed P-E needs to be delayed, and the message to be consumed P-E is not the first message to be consumed to be delayed in the call chain, so that the maximum waiting time mw (E) of the message to be consumed P-E is determined by the maximum waiting time mw (D) of the message to be consumed P-D and the delay time of the message to be consumed P-E, for example, the maximum waiting time mw (E) of the message to be consumed P-E is greater than or equal to the sum of the maximum waiting time mw (D) of the message to be consumed P-D and the delay time D (E) of the message to be consumed P-E, that is, mw (E) +mw (D) +mw (E), where mw (E) is the maximum waiting time mw (D) of the message to be consumed P-D and mw (E) is the delay time of the message to be consumed P-E.
The delay time D (B) of the message to be consumed P-B, the delay time D (D) of the message to be consumed P-D, and the delay time D (E) of the message to be consumed P-E are described in the foregoing, and will not be described in detail herein.
It should be noted that the pending message queue is a waiting message for storing messages with a waiting time exceeding the maximum waiting time, and some of the waiting messages are non-consumable messages and some of the waiting messages are consumable messages. The method can be manually rechecked or automatically rechecked.
In some embodiments, the maximum latency may be adjusted according to the actual situation. If the pending message queue has more consumable messages to be consumed, the maximum waiting time can be prolonged, and if the occupied storage space of the messages to be consumed in the pending message queue and the storage space provided by the system for the delay message queue occupy smaller space, the maximum waiting time can be prolonged, and at least the maximum waiting time is increased to the sum of the time for consuming all the messages to be consumed.
In some embodiments, as shown in fig. 3, step S203, in a case where the current message to be consumed does not satisfy the consumption condition, sends the current message to be consumed to the delay message queue, including:
step S301, when the current message to be consumed does not meet the consumption condition, the current message to be consumed is packaged for a preset waiting time.
Step S302, the current message to be consumed, which is packaged with the preset waiting time, is sent to a delay message queue.
In order to record the waiting time of the current message to be consumed conveniently, the current message to be consumed is packaged for preset waiting time before being sent to the delay message queue, the delay consuming queue and the consuming end can determine the waiting time of the current message to be consumed through the preset waiting time, and the consuming end is helpful for the consuming end to actively consume the current message to be consumed when necessary through the preset waiting time.
In some embodiments, the preset wait time is the sum of the time and the delay time that the current message to be consumed has completed waiting.
Wherein the time that the wait has been completed is the time that the current message to be consumed has been delayed in the delayed consume queue. In the embodiment of the disclosure, the current message to be consumed may be cached in the delay message queue multiple times, and the waiting time increases with the number of times of entering the delay message queue for caching. The delay time of the current message to be consumed entering the delay message queue can be equal or unequal. To better manage the delay cache queues, the delay times are equal each time.
Illustratively, the preset wait time satisfies the following rule: waittme (next) =waittme (current) +delay, where waittme (next) represents the time when the current message to be consumed has completed waiting when called again by the consumer, waittme (current) represents the time when the current message to be consumed has completed waiting at the time of the call, and delay represents the delay time. The length of waiting time for each time the current message to be consumed enters the delay message queue is delay time.
In some embodiments, after receiving the current message to be consumed, further comprising: and packaging the current message to be consumed with an initial waiting time, wherein the initial waiting time is 0.
For the current message to be consumed, which is called by the consuming end for the first time, the message enters a normal queue of the consuming end, and an initial waiting time can be bound so as to monitor the waiting time of the current message to be consumed later. Since the current message to be consumed has not entered the delayed message queue, the initial wait time is 0.
In some embodiments, after sending the current message to be consumed to the pending message queue, if the waiting time of the current message to be consumed reaches the maximum waiting time, the method further includes:
judging whether the current message to be consumed meets the consumption condition or not; discarding the current message to be consumed under the condition that the current message to be consumed does not meet the consumption condition; and consuming the current message to be consumed under the condition that the current message to be consumed meets the consumption condition.
In the embodiment of the disclosure, the current message to be consumed which does not satisfy the consumption condition may be a consumable message or a non-consumable message, so that the consumption condition is set, the current message to be consumed which does not satisfy the consumption condition is discarded, and the current message to be consumed which satisfies the consumption condition is consumed.
In some embodiments, it is determined, manually or automatically, whether the current message to be consumed satisfies the consumption condition.
It will be appreciated that the above-mentioned method embodiments of the present disclosure may be combined with each other to form a combined embodiment without departing from the principle logic, and are limited to the description of the present disclosure. It will be appreciated by those skilled in the art that in the above-described methods of the embodiments, the particular order of execution of the steps should be determined by their function and possible inherent logic.
For a better understanding of the data calling method provided by the present disclosure, the data calling method provided by the present disclosure may be understood in more detail through the following examples.
Fig. 4 is a flowchart of another data calling method provided in an embodiment of the present disclosure. As shown in fig. 4, the data calling method includes:
step S401, receiving the current message to be consumed.
In step S401, a current message to be consumed is received, and the current message to be consumed may be added to a normal consumption queue. The normal consumption queue can be arranged at the consumption end or in a device of a third party.
Step S402, the initial waiting time is packaged for the current message to be consumed, and a maximum waiting time is set.
In step S402, the initial waiting time is 0, and the maximum waiting time is set in the foregoing manner, which is not described herein.
Illustratively, the current message to be consumed P-B, which encapsulates the initial wait time, is denoted as P-B (w=0).
Step S403, judging whether the current message to be consumed meets the consumption condition, if yes, executing step S404; if the consumption condition is not satisfied, step S405 is executed.
Step S404, consuming the current message to be consumed.
The embodiment of the disclosure does not limit the consumption mode of the message to be consumed currently.
Step S405, judging whether the waiting time of the current message to be consumed is greater than or equal to the maximum waiting time; if not, executing step S406; if yes, go to step S408.
Step S406, the current message to be consumed is sent to a delay message queue.
In step S406, a preset waiting time is encapsulated for the current message to be consumed, where the preset waiting time is a cumulative delay time based on the previous waiting time, and may be denoted as P-B (w+d).
In step S407, the waiting time length of the current message to be consumed in the delay message queue is the delay time.
In step S407, the current message to be consumed may be automatically pushed to the consumer by the delayed message queue, or may be actively pulled by the consumer, and then the current message to be consumed returns to step S403 again.
Step S408, the current message to be consumed is sent to the pending message queue.
Step S409, judging whether the current message to be consumed meets the consumption condition, if so, executing step S404; if not, step S410 is performed.
In step S409, it may be manually interposed to determine whether the current message to be consumed satisfies the consumption condition.
Step S410, discard the current message to be consumed.
In addition, the embodiment of the disclosure further provides a data calling device, and fig. 5 is a block diagram of the data calling device provided by the embodiment of the disclosure. Referring to fig. 5, an embodiment of the present disclosure provides a data calling apparatus 500, including:
a receiving module 501, configured to receive a current message to be consumed.
The current message to be consumed is a message to be consumed received by a consumer, and the message to be consumed is a message generated by a producer.
A first determining module 502, configured to determine whether the current message to be consumed meets the consumption condition.
The consumption condition is a basis for judging whether the current message to be consumed can be consumed or not. The consumption condition is determined based on the attributes of the message to be consumed. In the embodiment of the disclosure, a consumption condition may be set for each message to be consumed.
A sending module 503, configured to send the current message to be consumed to the delay message queue if the current message to be consumed does not meet the consumption condition.
The delay message queue is arranged in a storage space outside the consumption end, namely, the delay message queue does not occupy storage and cache resources of the consumption end, so that the demand on the consumption end resources is reduced.
The first determining module 502 is further configured to, when the current message to be consumed reaches the delay time at the time of the delay message queue, perform determining again whether the current message to be consumed meets the consumption condition.
And a consumption module 504, configured to consume the current message to be consumed if the current message to be consumed meets the consumption condition.
In some embodiments, the data calling apparatus 500 further comprises:
a second determining module 505, configured to determine whether the waiting time of the current message to be consumed reaches a preset maximum waiting time.
The sending module 503 is further configured to send the current message to be consumed to the pending message queue if the waiting time of the current message to be consumed reaches the maximum waiting time.
In some embodiments, the data calling apparatus 500 further comprises:
the encapsulation module 506 encapsulates the current message to be consumed for a preset waiting time when the current message to be consumed does not meet the consumption condition.
The sending module 503 is further configured to send the current message to be consumed, which is encapsulated with the preset waiting time, to the delay message queue.
In some embodiments, the encapsulation module 506 is further configured to encapsulate the current message to be consumed with an initial latency, where the initial latency is 0.
In some embodiments, the data calling apparatus 500 further comprises:
a third judging module 507, configured to judge whether the current message to be consumed meets the consumption condition.
And a discarding module 508, configured to discard the current message to be consumed if the current message to be consumed does not satisfy the consumption condition.
The consumption module 504 is further configured to consume the current message to be consumed if the current message to be consumed meets the consumption condition.
It should be noted that, the data calling device provided in the embodiment of the present disclosure may be used to implement any data calling method provided in the present disclosure, and the corresponding technical solutions and descriptions and corresponding descriptions referring to the method parts will not be repeated.
According to the data calling device provided by the embodiment of the disclosure, the first judging module judges whether the current message to be consumed meets the consumption condition, the sending module caches the current message to be consumed to the delay message queue under the condition that the current message to be consumed does not meet the consumption condition, service decoupling is achieved, after the current message to be consumed reaches the preset delay time, the first judging module judges whether the consumption condition is met again, if the current message to be consumed meets the consumption condition, the consumption module consumes the current message to be consumed, and the current message to be consumed is not accumulated at the consumption end due to the fact that the delay message queue is arranged in a storage space outside the consumption end, occupation of resources of the consumption end is reduced, and performance bottleneck of a database of the consumption end is relieved; the design logic is simple, a background program is not required to be arranged at the consumption end, the complexity and difficulty of the design of the consumption end are not increased, parallel calling is supported, and the processing efficiency is improved.
The data calling method and the data calling device can be applied to any scene requiring data calling, and the scene to which the method and the device can be applied comprises but is not limited to an online shopping system.
Fig. 6 is a block diagram of an electronic device according to an embodiment of the present disclosure.
Referring to fig. 6, an embodiment of the present disclosure provides an electronic device 600 including: at least one processor 601; at least one memory 602, and one or more I/O interfaces 603, connected between the processor 601 and the memory 602; the memory 602 stores one or more computer programs executable by the at least one processor 601, and the one or more computer programs are executed by the at least one processor 601 to enable the at least one processor 601 to perform the data calling method described above.
The disclosed embodiments also provide a computer readable storage medium having a computer program stored thereon, wherein the computer program when executed by a processor/processing core implements the data invoking method described above. The computer readable storage medium may be a volatile or nonvolatile computer readable storage medium.
Those of ordinary skill in the art will appreciate that all or some of the steps, systems, functional modules/units in the apparatus, and methods disclosed above may be implemented as software, firmware, hardware, and suitable combinations thereof. In a hardware implementation, the division between the functional modules/units mentioned in the above description does not necessarily correspond to the division of physical components; for example, one physical component may have multiple functions, or one function or step may be performed cooperatively by several physical components. Some or all of the physical components may be implemented as software executed by a processor, such as a central processing unit, digital signal processor, or microprocessor, or as hardware, or as an integrated circuit, such as an application specific integrated circuit. Such software may be distributed on computer-readable storage media, which may include computer storage media (or non-transitory media) and communication media (or transitory media).
The term computer storage media includes both volatile and nonvolatile, removable and non-removable media implemented in any method or technology for storage of information such as computer readable program instructions, data structures, program modules or other data, as known to those skilled in the art. Computer storage media includes, but is not limited to, random Access Memory (RAM), read Only Memory (ROM), erasable Programmable Read Only Memory (EPROM), static Random Access Memory (SRAM), flash memory or other memory technology, portable compact disc read only memory (CD-ROM), digital Versatile Discs (DVD) or other optical disc storage, magnetic cassettes, magnetic tape, magnetic disk storage or other magnetic storage devices, or any other medium which can be used to store the desired information and which can be accessed by a computer. Furthermore, as is well known to those of ordinary skill in the art, communication media typically embodies computer readable program instructions, data structures, program modules or other data in a modulated data signal such as a carrier wave or other transport mechanism and may include any information delivery media.
The computer readable program instructions described herein may be downloaded from a computer readable storage medium to a respective computing/processing device or to an external computer or external storage device over a network, such as the internet, a local area network, a wide area network, and/or a wireless network. The network may include copper transmission cables, fiber optic transmissions, wireless transmissions, routers, firewalls, switches, gateway computers and/or edge servers. The network interface card or network interface in each computing/processing device receives computer readable program instructions from the network and forwards the computer readable program instructions for storage in a computer readable storage medium in the respective computing/processing device.
Computer program instructions for performing the operations of the present disclosure can be assembly instructions, instruction Set Architecture (ISA) instructions, machine-related instructions, microcode, firmware instructions, state setting data, or source or object code written in any combination of one or more programming languages, including an object oriented programming language such as Smalltalk, c++ or the like and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The computer readable program instructions may be executed entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any kind of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or may be connected to an external computer (for example, through the Internet using an Internet service provider). In some embodiments, aspects of the present disclosure are implemented by personalizing electronic circuitry, such as programmable logic circuitry, field Programmable Gate Arrays (FPGAs), or Programmable Logic Arrays (PLAs), with state information of computer readable program instructions, which can execute the computer readable program instructions.
The computer program product described herein may be embodied in hardware, software, or a combination thereof. In an alternative embodiment, the computer program product is embodied as a computer storage medium, and in another alternative embodiment, the computer program product is embodied as a software product, such as a software development kit (Software Development Kit, SDK), or the like.
Various aspects of the present disclosure are described herein with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems) and computer program products according to embodiments of the disclosure. It will be understood that each block of the flowchart illustrations and/or block diagrams, and combinations of blocks in the flowchart illustrations and/or block diagrams, can be implemented by computer-readable program instructions.
These computer readable program instructions may be provided to a processor of a general purpose computer, special purpose computer, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions/acts specified in the flowchart and/or block diagram block or blocks. These computer readable program instructions may also be stored in a computer readable storage medium that can direct a computer, programmable data processing apparatus, and/or other devices to function in a particular manner, such that the computer readable medium having the instructions stored therein includes an article of manufacture including instructions which implement the function/act specified in the flowchart and/or block diagram block or blocks.
The computer readable program instructions may also be loaded onto a computer, other programmable data processing apparatus, or other devices to cause a series of operational steps to be performed on the computer, other programmable apparatus or other devices to produce a computer implemented process such that the instructions which execute on the computer, other programmable apparatus or other devices implement the functions/acts specified in the flowchart and/or block diagram block or blocks.
The flowcharts and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of instructions, which comprises one or more executable instructions for implementing the specified logical function(s). In some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
Example embodiments have been disclosed herein, and although specific terms are employed, they are used and should be interpreted in a generic and descriptive sense only and not for purpose of limitation. In some instances, it will be apparent to one skilled in the art that features, characteristics, and/or elements described in connection with a particular embodiment may be used alone or in combination with other embodiments unless explicitly stated otherwise. It will be understood by those skilled in the art that various changes in form and details may be made therein without departing from the scope of the disclosure as set forth in the appended claims.

Claims (10)

1. A data calling method, comprising:
receiving a current message to be consumed;
judging whether the current message to be consumed meets the consumption condition or not;
transmitting the current message to be consumed to a delay message queue under the condition that the current message to be consumed does not meet the consumption condition; the delay message queue is arranged in a storage space outside the consumption end;
executing the judgment again if the current message to be consumed meets the consumption condition under the condition that the time of the current message to be consumed in the delay message queue reaches the delay time;
And consuming the current message to be consumed under the condition that the current message to be consumed meets the consumption condition.
2. The method according to claim 1, wherein the sending the current message to be consumed to a delayed message queue before the current message to be consumed does not satisfy a consumption condition, further comprises:
judging whether the waiting time of the current message to be consumed reaches the preset maximum waiting time or not;
and sending the current message to be consumed to a pending message queue under the condition that the waiting time of the current message to be consumed reaches the maximum waiting time.
3. The method according to claim 2, wherein said sending the current message to be consumed to a delayed message queue if the current message to be consumed does not meet a consumption condition comprises:
under the condition that the current message to be consumed does not meet the consumption condition, packaging the current message to be consumed for a preset waiting time;
and sending the current message to be consumed, which is packaged with the preset waiting time, to a delay message queue.
4. The method of claim 2, wherein the delay time is determined according to a consumption time required for a message to be consumed arranged before the current message to be consumed in a call chain arranged in a consumption order of the message to be consumed;
The delay time is greater than or equal to a sum of consumption times required for messages to be consumed arranged before the current message to be consumed in the call chain.
5. The method of claim 2, wherein the maximum waiting time is determined in accordance with a delay time required for a message to be consumed arranged before the current message to be consumed in a call chain; the delay time is determined according to the consumption time required by the message to be consumed arranged before the current message to be consumed in a call chain, and the call chain is arranged according to the consumption sequence of the message to be consumed.
6. The method of claim 5, wherein the maximum waiting time of the message to be consumed for which the first time delay is required in the call chain is k times the delay time of the message to be consumed; wherein k is a number greater than 1;
the maximum waiting time of the messages to be consumed except the first message to be consumed needing to be delayed in the call chain is larger than or equal to the sum of the delay time of the messages to be consumed and the maximum waiting time of the previous messages to be consumed.
7. The method of claim 1, wherein the consumption condition comprises that messages to be consumed arranged in a call chain before the current message to be consumed have been consumed, wherein a consumption order of the messages to be consumed is determined based on attributes of the messages to be consumed.
8. A data recall device, comprising:
the receiving module is used for receiving the current message to be consumed;
the first judging module is used for judging whether the current message to be consumed meets the consumption condition or not;
the sending module is used for sending the current message to be consumed to a delay message queue under the condition that the current message to be consumed does not meet the consumption condition; the delay message queue is arranged in a storage space outside the consumption end;
the first judging module is further configured to execute the judging whether the current message to be consumed meets a consumption condition again when the time of the current message to be consumed in the delay message queue reaches a delay time;
and the consumption module is used for consuming the current message to be consumed under the condition that the current message to be consumed meets the consumption condition.
9. An electronic device, comprising:
at least one processor; and
a memory communicatively coupled to the at least one processor; wherein,
the memory stores one or more computer programs executable by the at least one processor to enable the at least one processor to perform the data call method of any one of claims 1-7.
10. A computer readable storage medium, on which a computer program is stored, characterized in that the computer program, when being executed by a processor, implements the data invoking method according to any of claims 1-7.
CN202210948925.3A 2022-08-09 2022-08-09 Data calling method and device, electronic equipment and computer readable storage medium Pending CN117633044A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210948925.3A CN117633044A (en) 2022-08-09 2022-08-09 Data calling method and device, electronic equipment and computer readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210948925.3A CN117633044A (en) 2022-08-09 2022-08-09 Data calling method and device, electronic equipment and computer readable storage medium

Publications (1)

Publication Number Publication Date
CN117633044A true CN117633044A (en) 2024-03-01

Family

ID=90034298

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210948925.3A Pending CN117633044A (en) 2022-08-09 2022-08-09 Data calling method and device, electronic equipment and computer readable storage medium

Country Status (1)

Country Link
CN (1) CN117633044A (en)

Similar Documents

Publication Publication Date Title
CN110662085B (en) Message sending method, device, readable medium and electronic equipment
US8094797B2 (en) Service provisioning and activation engines for system
KR101006114B1 (en) Content push service
CN104468629A (en) Method and device for transmitting information in batches
US8467815B2 (en) Mobile address book population using SMS polling
CN111181873B (en) Data transmission method, data transmission device, storage medium and electronic equipment
CN101809950A (en) Method and apparatus for performing load balancing for a control plane of a mobile communication network
CN105791381A (en) Access control method and apparatus
CN110830388B (en) Data scheduling method, device, network equipment and computer storage medium
US8201070B2 (en) System and method for pre-calculating checksums
CN114205762A (en) Short message flow control method, equipment and storage medium
CN110650209A (en) Method and device for realizing load balance
US20150304227A1 (en) Queue Management Method and Apparatus
CN113630310A (en) Distributed high-availability gateway system
CN107959667A (en) A kind of method for pushing of media slicing, server and client
CN117633044A (en) Data calling method and device, electronic equipment and computer readable storage medium
CN103647622A (en) Method, apparatus and system for realizing computer room-spanning data transmission
EP3657859A1 (en) Method for optimising the data exchange between connected objects by message type
CN112202914B (en) Message pushing method and device
JP2011091711A (en) Node, method for distributing transmission frame, and program
CN108243091B (en) Information sharing device and information sharing method
CN111859877A (en) Method and device for realizing excel import and export
CN104468841A (en) Method and device for transmitting information in batches
CN102449979B (en) System, method and device for improving performences of content sharing system including content sharing client terminal
CN113342837B (en) Data transmission method, device, electronic equipment and computer readable medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination