CN116974782A - Event bus switching method, device, computer equipment and storage medium - Google Patents
Event bus switching method, device, computer equipment and storage medium Download PDFInfo
- Publication number
- CN116974782A CN116974782A CN202310804565.4A CN202310804565A CN116974782A CN 116974782 A CN116974782 A CN 116974782A CN 202310804565 A CN202310804565 A CN 202310804565A CN 116974782 A CN116974782 A CN 116974782A
- Authority
- CN
- China
- Prior art keywords
- event
- bus
- target
- event bus
- gray
- 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
Links
- 238000000034 method Methods 0.000 title claims abstract description 62
- 230000004044 response Effects 0.000 claims abstract description 52
- 230000001960 triggered effect Effects 0.000 claims abstract description 15
- 238000004590 computer program Methods 0.000 claims description 28
- 230000003139 buffering effect Effects 0.000 description 5
- 238000010586 diagram Methods 0.000 description 5
- 238000011144 upstream manufacturing Methods 0.000 description 4
- 238000006243 chemical reaction Methods 0.000 description 2
- 238000005516 engineering process Methods 0.000 description 2
- 230000001360 synchronised effect Effects 0.000 description 2
- 230000005856 abnormality Effects 0.000 description 1
- 230000009977 dual effect Effects 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 230000003068 static effect Effects 0.000 description 1
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/46—Multiprogramming arrangements
- G06F9/54—Interprogram communication
- G06F9/542—Event management; Broadcasting; Multicasting; Notifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/46—Multiprogramming arrangements
- G06F9/54—Interprogram communication
- G06F9/546—Message passing systems or structures, e.g. queues
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F2209/00—Indexing scheme relating to G06F9/00
- G06F2209/54—Indexing scheme relating to G06F9/54
- G06F2209/544—Remote
Landscapes
- Engineering & Computer Science (AREA)
- Software Systems (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Multimedia (AREA)
- Traffic Control Systems (AREA)
Abstract
The application relates to an event bus switching method, an event bus switching device, computer equipment and a storage medium. The method comprises the following steps: after the event bus switching instruction is triggered, responding to a consumption request of a target event, and acquiring gray level configuration information of the target event; determining an event bus corresponding to a target event, and judging whether the gray configuration information hits the switching gray when the event bus corresponding to the target event comprises a first event bus; wherein the switching gray scale is used to control the proportion of events allowed to switch to the second event bus; responding to the gray configuration information hit switching gray, judging whether the current time is within a preset buffer time period or not; and in response to the current time being within a preset buffer period, callback the target event from the first event bus for consumption. The method can improve the stability of event bus switching.
Description
Technical Field
The present application relates to the field of computer technologies, and in particular, to a method and apparatus for switching an event bus, a computer device, and a storage medium.
Background
Along with the development of computer technology, software systems are updated continuously, and a scene of parallel or switching between new and old systems is necessarily present in actual business, so that how to ensure that the switching between the new and old systems does not influence the operation of the business is a frequently occurring problem. For example, in many internet enterprises, using event bus systems, how to smoothly switch between new and old event buses is an urgent problem to be solved.
In the traditional method, a dual-system parallel switching mode is adopted, the dual systems are parallel for a period of time and then switched according to the event dimension, however, the data of the new system and the old system may be repeated during the parallel period, and the problem of event loss may exist in the switching process because the consumption of the new system and the old system generally has time difference.
Disclosure of Invention
In view of the foregoing, it is desirable to provide an event bus switching method, apparatus, computer device, and storage medium capable of preventing event loss during event bus switching.
An event bus switching method, the method comprising:
after the event bus switching instruction is triggered, responding to a consumption request of a target event, and acquiring gray level configuration information of the target event;
Determining an event bus corresponding to a target event, and judging whether the gray configuration information hits the switching gray when the event bus corresponding to the target event comprises a first event bus; wherein the switching gray scale is used to control the proportion of events allowed to switch to the second event bus;
responding to the gray configuration information hit switching gray, judging whether the current time is within a preset buffer time period or not;
and in response to the current time being within a preset buffer period, callback the target event from the first event bus for consumption.
In some embodiments, before obtaining the gray scale configuration information of the target event in response to the consumption request of the target event, the method further comprises:
reporting the associated event to a first event bus and a second event bus in response to an event bus switching instruction; the related event is an event carrying the same event identifier in a link of the first event bus and a link of the second event bus.
In some embodiments, reporting the associated event to the first event bus and the second event bus includes:
acquiring standard event parameters of an event to be reported;
generating an event identifier for the event to be reported according to the standard event parameters;
And adding the generated event identifier into the message body of the event to be reported, generating the associated event, and reporting the associated event to the first event bus and the second event bus at the same time.
In some embodiments, callback of the target event from the first event bus for consumption in response to the current time being within a preset buffer period comprises:
acquiring an event identifier of a target event in response to the current time in a preset buffer time period;
judging whether the target event is processed or not according to the event identification of the target event;
in response to the target event not being processed, the target event is recalled from the first event bus for consumption.
In some embodiments, the method further comprises:
when the event bus corresponding to the target event comprises a second event bus, judging whether the gray configuration information hits to switch gray and judging whether the current time is after the event bus switching instruction triggers;
responding to the gray level configuration information to hit the switching gray level and acquiring an event identifier of the target event after the event switching instruction triggers the current time;
judging whether the target event is processed or not according to the event identification of the target event;
And in response to the target event not being processed, callback the target event from the second event bus for consumption.
In some embodiments, after determining whether the gray configuration information hits the switching gray when the event bus corresponding to the target event includes the first event bus, the method further includes:
responding to the gray configuration information without hit to switch gray, and acquiring an event identifier of a target event;
judging whether the target event is processed or not according to the event identification of the target event;
in response to the target event not being processed, the target event is recalled from the first event bus for processing.
In some embodiments, the method further comprises:
after all the events to be processed are switched from the first event bus to the second event bus for consumption, judging whether the first event bus has an associated event consumption end or not;
if the first event bus does not have the associated event consuming end server, updating the configuration of the event generating end server to cut off the link of the newly generated event to be reported to report the first event bus.
An event bus switching device, the device comprising:
the gray level configuration acquisition module is used for responding to the consumption request of the target event after the event bus switching instruction is triggered to acquire the gray level configuration information of the target event;
The event bus determining module is used for determining an event bus corresponding to the target event, and judging whether the gray configuration information hits the switching gray when the event bus corresponding to the target event comprises a first event bus; wherein the switching gray scale is used to control the proportion of events allowed to switch to the second event bus;
the buffer time judging module is used for responding to the hit switching gray of the gray configuration information and judging whether the current time is within a preset buffer time period or not;
and the target event callback module is used for callback a target event from the first event bus for consumption in response to the current time within a preset buffer time period.
A computer device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, the processor implementing the event bus switching method of any of the above when executing the computer program.
A computer readable storage medium having stored thereon a computer program which when executed by a processor implements the event bus switching method of any of the above.
According to the event bus switching method, the device, the computer equipment and the storage medium, when the event bus corresponding to the target event comprises the old event bus, even if the gray level configuration information of the target event hits the switching gray level of the new event bus, the path for event consumption from the old event bus is provided as long as the current time is within the preset buffer time period, so that the event consumption terminal can simultaneously support the downstream event consumption terminal to simultaneously consume events from the new event bus and the old event bus within the preset buffer time period, and the event loss caused by consumption time difference in the switching process of the new event bus and the old event bus is prevented.
Drawings
FIG. 1 is a diagram of an application environment for an event bus switching method in one embodiment;
FIG. 2 is a flow chart of an event bus switching method according to an embodiment;
FIG. 3 is a flow chart illustrating reporting of an associated event to a first event bus and a second event bus in one embodiment;
FIG. 4 is a flow chart illustrating an event bus switching method according to another embodiment;
FIG. 5 is a flow chart of a method for event bus switching in an application example;
FIG. 6 is a block diagram of an event bus switching device in one embodiment;
fig. 7 is an internal structural diagram of a computer device in one embodiment.
Detailed Description
The present application will be described in further detail with reference to the drawings and examples, in order to make the objects, technical solutions and advantages of the present application more apparent. It should be understood that the specific embodiments described herein are for purposes of illustration only and are not intended to limit the scope of the application.
The event bus switching method provided by the application can be applied to an application environment shown in figure 1. Wherein, the server 102 at the event generating end, the server 104 at the event consuming end and the server 106 at the event center system communicate with each other through a network.
In some embodiments, after the event bus switching instruction is triggered, in response to a consumption request of a target event triggered by the server 104 at the event consuming side, the server 106 of the event center system acquires gray configuration information of the target event generated by the server 102 at the event generating side, determines an event bus corresponding to the target event, determines whether the gray configuration information hits a switching gray when the event bus corresponding to the target event includes a first event bus, determines whether the current time is within a preset buffer time period in response to the gray configuration information hitting the switching gray, and recalls the target event from the first event bus for consumption by the server 104 at the event consuming side in response to the current time being within the preset buffer time period.
The server 102 at the event generating side, the server 106 at the event center system, and the server 104 at the event consuming side may be implemented by a server stand alone or a server cluster formed by a plurality of servers, or may be implemented by a cloud server or the like. The server 106 of the event center system may implement the above steps based on the SDK (software development kit).
In one embodiment, as shown in fig. 2, an event bus switching method is provided, which is illustrated by taking a server of the event center system in fig. 1 as an example, and may include the following steps:
Step S202: after the event bus switching instruction is triggered, the gray scale configuration information of the target event is obtained in response to the consumption request of the target event.
The target event refers to an event to be consumed, which is determined at a specific time point according to business logic of event processing. Specifically, according to an event conversion sub-flow in the business logic, a consumption request for a target event is triggered, and a server receives the consumption request of the target event and reads gray configuration information corresponding to the target event.
Illustratively, the gray configuration information may include at least one of event type (eventCode), event identification (msgId), buffer time interval, subject ID, and the like.
Step S204: determining an event bus corresponding to a target event, and judging whether the gray configuration information hits the switching gray when the event bus corresponding to the target event comprises a first event bus; wherein the switching gray scale is used to control the proportion of events that are allowed to switch to the second event bus.
The first event bus may be an old event bus, i.e. an event bus to be replaced, and the second event bus may be a new event bus, i.e. an event bus to be switched to. By setting the switching gradation, an event hitting the switching gradation can be switched from the first event bus to the second event bus for consumption.
In this step, the server may identify, by reading the gray configuration information of the target event, that the target event is an event reported through which reporting link, for example, if the target event is an event reported through a reporting link of the first event bus, it may be determined that the event bus corresponding to the target bus includes the first event bus, if the target event is an event reported through a reporting link of the second event bus, it may be determined that the event bus corresponding to the target event includes the second event bus, and if the target bus reports both the first event bus and the second event bus, it may be determined that the event bus corresponding to the target event includes the first event bus, and also may be determined that the event bus corresponding to the target bus includes the second event bus.
Illustratively, the switching gray level may be set in advance, and the event hitting the switching gray level may be gradually increased from 0% to 100% by gradually adjusting the value of the switching gray level, so as to control the event consumption to switch from the first event bus to the second event bus at a certain switching rate, for example:
if the preset switching gray value is: 0,1, C, then an event beginning with 0 or 1 or C representing the event identification in the gray configuration information will hit the switching gray.
If the preset switching gray value is: a, the event in the gray configuration information identifies an event beginning with a (or a, case-insensitive) that hits the switching gray.
If the preset switching gray value is: 1A, B, then an event beginning with 1A (or 1A, case-less) or B representing an event identification in the gray configuration information will hit the switching gray.
It should be noted that, the specific gray level switching, the setting manner of the gray level configuration information, and the conditions and rules for determining whether the gray level configuration information hits the gray level switching may be configured according to the need, so long as a certain proportion of partial events or all events can be controlled from all events, and the events are selected as events to be switched to a new event bus.
Step S206: and responding to the gray scale configuration information hit switching gray scale, and judging whether the current time is within a preset buffer time period.
The current time refers to a current time point or a current time period of a consumption request triggering a target event; the preset buffer time period refers to a preset certain time period after the event bus switching instruction is triggered.
Specifically, in response to the gray level configuration information of the target event hitting the switching gray level, the server may read a start time point and an end time point of the preset buffer time period, determine whether the current time is after the start time point and before the end time point, and if so, the server may determine that the current time is within the preset buffer time period. Further, if the current time is not after the start time point of the preset buffering period or is not before the end time point of the preset buffering period, the current operation may be ended.
Step S208: and in response to the current time being within a preset buffer period, callback the target event from the first event bus for consumption.
Specifically, in response to the current time being within the preset buffer period, the server may callback the target event from the first time bus and send the target event to the server of the event consuming side for consumption by the server of the event consuming side.
According to the event bus switching method, when the event bus corresponding to the target event comprises the old event bus, even if the gray level configuration information of the target event hits the switching gray level of the new event bus, a path for event consumption from the old event bus is provided as long as the current time is within the preset buffer time period, so that the downstream event consumption terminal can be simultaneously supported to consume events from the new event bus and the old event bus within the preset buffer time period, and event loss caused by consumption time difference in the switching process of the new event bus and the old event bus is prevented.
In some embodiments, before obtaining the gray scale configuration information of the target event in response to the consumption request of the target event, the method further comprises: reporting the associated event to a first event bus and a second event bus in response to an event bus switching instruction; the related event is an event carrying the same event identifier in a link of the first event bus and a link of the second event bus.
According to the embodiment, after the event bus switching instruction is triggered, the first event bus and the second event bus can be started in parallel, events in the first event bus and the second event bus are associated, and the associated events are reported to the first event bus and the second event bus at the same time.
In some embodiments, reporting the associated event to the first event bus and the second event bus includes: acquiring standard event parameters of an event to be reported; generating an event identifier for the event to be reported according to the standard event parameters; and adding the generated event identifier into a message body of the event to be reported, generating an associated event, and reporting the associated event to the first event bus and the second event bus simultaneously.
In this embodiment, a unique ID (universal unique identifier) may be generated for the same event through a UUID (universal unique identifier) algorithm to be used as an event identifier, and the unique ID is added to the message body of the message event of the new and old links at the same time, so as to correlate the same event in the new and old event buses. For the event to be reported generated after the switching starts, an event identifier can be generated through a UUID algorithm, and the event carrying the same event identifier is used as an associated event to be reported to the first event bus and the second event bus respectively.
A schematic diagram of reporting the associated event to both the first event bus and the second event bus is shown in fig. 3, for example. As can be seen from fig. 3, when switching to a new event bus (a second event bus, for example, kafka) is required to report an event to a link of the new event bus, the reporting link of the first event bus is taken over by the reporting link of the second event bus by the method of the present embodiment, and by adding a unique ID to the event and by reading the configuration of the event, the link of the first event bus and the link of the second event bus can be reported simultaneously by the associated event.
In some embodiments, callback of the target event from the first event bus for consumption in response to the current time being within a preset buffer period comprises: acquiring an event identifier of a target event in response to the current time in a preset buffer time period; judging whether the target event is processed or not according to the event identification of the target event; in response to the target event not being processed, the target event is recalled from the first event bus for consumption.
In this embodiment, after determining that the current time is within the preset buffer period, in order to avoid that the downstream consumer side repeatedly processes the same event, whether the target event has been processed may be further determined according to the event identifier added by the target event, where the first event bus and the second event bus have the same event identifier in the link of the first event bus and the second event bus, that is, the same event has the same event identifier in the link of the first event bus and the second event bus, so, according to the event identifier of the target event, through idempotent operation, it may be determined whether the target event has been consumed in the consumption link of the second event bus, and if not, the target event may be recalled from the first event bus for consumption by the downstream consumer side. By the embodiment, the business system at the downstream consumer side can be prevented from repeatedly processing the same event while preventing the event from being lost.
In some embodiments, the method further comprises: when the event bus corresponding to the target event comprises a second event bus, judging whether the gray configuration information hits the switching gray and judging whether the current time is after the event bus switching instruction triggers; responding to the gray configuration information to hit and switch gray, and acquiring an event identifier of a target event after the current time is triggered by an event switching instruction; judging whether the target event is processed or not according to the event identification of the target event; in response to the target event not being processed, the target event is recalled from the second event bus for consumption.
In this embodiment, after the switching of the event bus is started, for the event reported by the second event bus, if the event hits the switching gray level of the second event bus, the event may be switched to the second event bus for consumption, and whether the event has been consumed in the link of the first event bus may be checked through an idempotent operation by using the event identifier of the target event, and if not, the target event may be recalled from the second event bus for consumption by the downstream consumer.
The flow of event processing during an event bus switch is described in further detail below in conjunction with an application example, and is shown in fig. 4. Specifically, the following contents can be included:
triggering a consumption request for a target event in an event conversion sub-flow, and entering step S401;
s401: reading gray scale configuration of a target event;
s402: determining an event bus corresponding to the reported target event, if the old event bus is reported, entering S403, and if the new event bus is reported, entering S408;
s403: whether the switching gray level of the new event bus is hit or not is judged, if yes, the step S404 is entered, and if not, the step S406 is entered.
S404: if the current time is after the start of the preset buffer period, if so, step S405 is entered, and if not, the process may be ended.
S405: if the current time is before the end of the preset buffer period, if yes, the step S406 is entered, and if not, the process may be ended.
S406: whether the target event is processed is judged, if not, the process proceeds to step S407, and if yes, the process may be ended.
S407: content callbacks for the target event are made from the old event bus.
S408: judging whether the gray level configuration of the target event hits the switching gray level of the new event bus and whether the current time is after the switching starts, if so, proceeding to step S409, if not, ending the process.
S409: whether the target event is processed is determined, if so, step S410 is executed, and if not, the process may be ended.
S410: content callback of the target event is performed from the new event bus.
According to the application example, through the preset information of gray level configuration, switching gray level, buffering time period and the like, the downstream consumption end can consume the new event bus from the new event bus and the old event bus in the buffering time period after the event bus is switched, after the buffering time period, only the event of the new event bus is consumed, the switching gray level is adjusted step by step, the event switching condition of the new event bus and the old event bus is observed, and finally all the events are switched to the new event bus.
In some embodiments, the method further comprises: establishing association with a server of an event generating end, namely accessing the server of the upstream event generating end into an event center SDK; the server of the event consuming end is connected to the event center SDK.
In some embodiments, the method further comprises: and judging whether an abnormality occurs in the switching process by comparing logs of the first event bus and the second event bus, if so, triggering an alarm to inform related personnel to process, if not, judging whether the switching gray level has reached the allowable 100% of events to switch to the second event bus, if so, entering a step of judging whether the first event bus has an associated event consumption end, and if not, adjusting the switching gray level.
For example, the adjustment of the switching gradation may be specifically: the percentage of switching gray is increased by a certain preset ratio, that is, the ratio of events allowed to be switched to the second event bus processing (the ratio of events hitting the switching gray is increased) is increased until the switching gray reaches the ratio allowing 100% of the events to be switched to the second event bus.
In some embodiments, after all events to be processed are switched from the first event bus to consuming from the second event bus, it may be determined whether the first event bus has an associated event consuming side; if the first event bus does not have the associated event consuming end server, updating the configuration of the event generating end server to cut off the link of the newly generated event to be reported to report the first event bus. By the embodiment, after the switching is judged to be completed, the upstream configuration can be automatically updated, so that the parallelism of the new event bus and the old event bus is ended, and the switching is completed.
Next, an application example is further described in connection with the event bus switching method, as shown in fig. 5, the method may be implemented based on an event center SDK, and for an event requiring gray scale, it is ensured that all upstream event generating terminals and downstream event consuming terminals access the SDK, and the event is correctly reported, and by checking whether the old event bus completely generates an event unique ID (event identifier). For the same event bus, gray scale can be opened to 100% at the consuming end for multiple times, further, the old event bus can be checked whether other consuming ends exist at the old event bus, if not, the upstream configuration is modified, and the old event bus is not reported any more.
It should be understood that, although the steps in the flowcharts of fig. 2-5 are shown in order as indicated by the arrows, these steps are not necessarily performed in order as indicated by the arrows. The steps are not strictly limited to the order of execution unless explicitly recited herein, and the steps may be executed in other orders. Moreover, at least some of the steps in fig. 2-5 may include multiple sub-steps or stages that are not necessarily performed at the same time, but may be performed at different times, nor do the order in which the sub-steps or stages are performed necessarily occur sequentially, but may be performed alternately or alternately with at least a portion of the sub-steps or stages of other steps or steps.
In one embodiment, as shown in fig. 6, there is provided an event bus switching device, including: a gray configuration acquisition module 602, an event bus determination module 604, a buffer time determination module 606, and a target event callback module 608, wherein:
the gray level configuration obtaining module 602 is configured to obtain gray level configuration information of a target event in response to a consumption request of the target event after the event bus switching instruction is triggered;
an event bus determining module 604, configured to determine an event bus corresponding to a target event, and determine whether the gray configuration information hits the switching gray when the event bus corresponding to the target event includes a first event bus; wherein the switching gray scale is used to control the proportion of events allowed to switch to the second event bus;
a buffer time judging module 606, configured to switch gray levels in response to the hit of the gray level configuration information, and judge whether the current time is within a preset buffer time period;
and the target event callback module 608 is configured to callback the target event from the first event bus for consumption in response to the current time being within the preset buffer period.
In some embodiments, the gray scale configuration acquisition module 602 is further configured to report the associated event to the first event bus and the second event bus in response to the event bus switching instruction; the related event is an event carrying the same event identifier in a link of the first event bus and a link of the second event bus.
In some embodiments, the gray configuration acquisition module 602 is further configured to acquire standard event parameters of an event to be reported; generating an event identifier for the event to be reported according to the standard event parameters; and adding the generated event identifier into the message body of the event to be reported, generating the associated event, and reporting the associated event to the first event bus and the second event bus at the same time.
In some embodiments, the buffer time judging module 606 is further configured to obtain an event identifier of the target event in response to the current time being within a preset buffer time period; judging whether the target event is processed or not according to the event identification of the target event; in response to the target event not being processed, the target event is recalled from the first event bus for consumption.
In some embodiments, the target event callback module 608 is further configured to determine whether the gray configuration information hits a switching gray and determine whether the current time is after an event bus switching command triggers when an event bus corresponding to the target event includes a second event bus; responding to the gray level configuration information to hit the switching gray level and acquiring an event identifier of the target event after the event switching instruction triggers the current time; judging whether the target event is processed or not according to the event identification of the target event; and in response to the target event not being processed, callback the target event from the second event bus for consumption.
In some embodiments, the target event callback module 608 is further configured to, when the event bus corresponding to the target event includes the first event bus, determine whether the gray configuration information hits the switching gray, and then, obtain the event identifier of the target event in response to the gray configuration information not hitting the switching gray; judging whether the target event is processed or not according to the event identification of the target event; in response to the target event not being processed, the target event is recalled from the first event bus for processing.
In some embodiments, the target event callback module 608 is further configured to determine whether the first event bus has an associated event consuming side after all the events to be processed are switched from the first event bus to being consumed from the second event bus; if the first event bus does not have the associated event consuming end server, updating the configuration of the event generating end server to cut off the link of the newly generated event to be reported to report the first event bus.
For specific limitations of the event bus switching device, reference may be made to the above limitations of the event bus switching method, and no further description is given here. The various modules in the event bus switching device described above may be implemented in whole or in part by software, hardware, or a combination thereof. The above modules may be embedded in hardware or may be independent of a processor in the computer device, or may be stored in software in a memory in the computer device, so that the processor may call and execute operations corresponding to the above modules.
In one embodiment, a computer device is provided, which may be a server, the internal structure of which may be as shown in fig. 7. The computer device includes a processor, a memory, and a network interface connected by a system bus. Wherein the processor of the computer device is configured to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, computer programs, and a database. The internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage media. The network interface of the computer device is used for communicating with an external terminal through a network connection. The computer program is executed by a processor to implement an event bus switching method.
It will be appreciated by those skilled in the art that the structure shown in FIG. 7 is merely a block diagram of some of the structures associated with the present inventive arrangements and is not limiting of the computer device to which the present inventive arrangements may be applied, and that a particular computer device may include more or fewer components than shown, or may combine some of the components, or have a different arrangement of components.
In one embodiment, a computer device is provided comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, the processor implementing the steps of when executing the computer program: after the event bus switching instruction is triggered, responding to a consumption request of a target event, and acquiring gray level configuration information of the target event; determining an event bus corresponding to a target event, and judging whether the gray configuration information hits the switching gray when the event bus corresponding to the target event comprises a first event bus; wherein the switching gray scale is used to control the proportion of events allowed to switch to the second event bus; responding to the gray configuration information hit switching gray, judging whether the current time is within a preset buffer time period or not; and in response to the current time being within a preset buffer period, callback the target event from the first event bus for consumption.
In some embodiments, the processor when executing the computer program further performs the steps of: reporting the associated event to a first event bus and a second event bus in response to an event bus switching instruction; the related event is an event carrying the same event identifier in a link of the first event bus and a link of the second event bus.
In some embodiments, the processor when executing the computer program further performs the steps of: acquiring standard event parameters of an event to be reported; generating an event identifier for the event to be reported according to the standard event parameters; and adding the generated event identifier into the message body of the event to be reported, generating the associated event, and reporting the associated event to the first event bus and the second event bus at the same time.
In some embodiments, the processor when executing the computer program further performs the steps of: acquiring an event identifier of a target event in response to the current time in a preset buffer time period; judging whether the target event is processed or not according to the event identification of the target event; in response to the target event not being processed, the target event is recalled from the first event bus for consumption.
In some embodiments, the processor when executing the computer program further performs the steps of: when the event bus corresponding to the target event comprises a second event bus, judging whether the gray configuration information hits to switch gray and judging whether the current time is after the event bus switching instruction triggers; responding to the gray level configuration information to hit the switching gray level and acquiring an event identifier of the target event after the event switching instruction triggers the current time;
In some embodiments, the processor when executing the computer program further performs the steps of: responding to the gray configuration information without hit to switch gray, and acquiring an event identifier of a target event; judging whether the target event is processed or not according to the event identification of the target event; in response to the target event not being processed, the target event is recalled from the first event bus for processing.
In some embodiments, the processor when executing the computer program further performs the steps of: after all the events to be processed are switched from the first event bus to the second event bus for consumption, judging whether the first event bus has an associated event consumption end or not; if the first event bus does not have the associated event consuming end server, updating the configuration of the event generating end server to cut off the link of the newly generated event to be reported to report the first event bus.
In one embodiment, a computer readable storage medium is provided having a computer program stored thereon, which when executed by a processor, performs the steps of: after the event bus switching instruction is triggered, responding to a consumption request of a target event, and acquiring gray level configuration information of the target event; determining an event bus corresponding to a target event, and judging whether the gray configuration information hits the switching gray when the event bus corresponding to the target event comprises a first event bus; wherein the switching gray scale is used to control the proportion of events allowed to switch to the second event bus; responding to the gray configuration information hit switching gray, judging whether the current time is within a preset buffer time period or not; and in response to the current time being within a preset buffer period, callback the target event from the first event bus for consumption.
In some embodiments, the computer program when executed by the processor further performs the steps of: reporting the associated event to a first event bus and a second event bus in response to an event bus switching instruction; the related event is an event carrying the same event identifier in a link of the first event bus and a link of the second event bus.
In some embodiments, the computer program when executed by the processor further performs the steps of: acquiring standard event parameters of an event to be reported; generating an event identifier for the event to be reported according to the standard event parameters; and adding the generated event identifier into the message body of the event to be reported, generating the associated event, and reporting the associated event to the first event bus and the second event bus at the same time.
In some embodiments, the computer program when executed by the processor further performs the steps of: acquiring an event identifier of a target event in response to the current time in a preset buffer time period; judging whether the target event is processed or not according to the event identification of the target event; in response to the target event not being processed, the target event is recalled from the first event bus for consumption.
In some embodiments, the computer program when executed by the processor further performs the steps of: when the event bus corresponding to the target event comprises a second event bus, judging whether the gray configuration information hits to switch gray and judging whether the current time is after the event bus switching instruction triggers; responding to the gray level configuration information to hit the switching gray level and acquiring an event identifier of the target event after the event switching instruction triggers the current time;
in some embodiments, the computer program when executed by the processor further performs the steps of: responding to the gray configuration information without hit to switch gray, and acquiring an event identifier of a target event; judging whether the target event is processed or not according to the event identification of the target event; in response to the target event not being processed, the target event is recalled from the first event bus for processing.
In some embodiments, the computer program when executed by the processor further performs the steps of: after all the events to be processed are switched from the first event bus to the second event bus for consumption, judging whether the first event bus has an associated event consumption end or not; if the first event bus does not have the associated event consuming end server, updating the configuration of the event generating end server to cut off the link of the newly generated event to be reported to report the first event bus.
Those skilled in the art will appreciate that all or part of the processes implementing the methods of the above embodiments may be implemented by a computer program for instructing relevant hardware, where the computer program may be stored on a non-volatile computer readable storage medium, and the computer program may include processes of the embodiments of the above methods when executed. Any reference to memory, storage, database, or other medium used in embodiments provided herein may include non-volatile and/or volatile memory. The nonvolatile memory can include Read Only Memory (ROM), programmable ROM (PROM), electrically Programmable ROM (EPROM), electrically Erasable Programmable ROM (EEPROM), or flash memory. Volatile memory can include Random Access Memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in a variety of forms such as Static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double Data Rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous Link DRAM (SLDRAM), memory bus direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), among others.
The technical features of the above embodiments may be arbitrarily combined, and all possible combinations of the technical features in the above embodiments are not described for brevity of description, however, as long as there is no contradiction between the combinations of the technical features, they should be considered as the scope of the description.
The above examples illustrate only a few embodiments of the application, which are described in detail and are not to be construed as limiting the scope of the application. It should be noted that it will be apparent to those skilled in the art that several variations and modifications can be made without departing from the spirit of the application, which are all within the scope of the application. Accordingly, the scope of protection of the present application is to be determined by the appended claims.
Claims (10)
1. An event bus switching method, the method comprising:
after the event bus switching instruction is triggered, responding to a consumption request of a target event, and acquiring gray configuration information of the target event;
determining an event bus corresponding to the target event, and judging whether the gray configuration information hits a switching gray when the event bus corresponding to the target event comprises a first event bus; wherein the switching gray scale is used to control the proportion of events allowed to switch to the second event bus;
Responding to the gray configuration information to hit the switching gray, and judging whether the current time is within a preset buffer time period or not;
and in response to the current time being within the preset buffer time period, callback the target event from the first event bus for consumption.
2. The method of claim 1, wherein prior to obtaining the gray scale configuration information for the target event in response to the consumption request for the target event, the method further comprises:
reporting the associated event to a first event bus and a second event bus in response to an event bus switching instruction; the related event is an event carrying the same event identifier in the links of the first event bus and the second event bus.
3. The method of claim 2, wherein reporting the associated event to the first event bus and the second event bus comprises:
acquiring standard event parameters of an event to be reported;
generating an event identifier for the event to be reported according to the standard event parameters;
and adding the generated event identifier into the message body of the event to be reported, generating the associated event, and reporting the associated event to the first event bus and the second event bus at the same time.
4. The method of claim 1, wherein the callback of the target event from the first event bus for consumption in response to the current time being within the preset buffer period comprises:
acquiring an event identifier of the target event in response to the current time within the preset buffer time period;
judging whether the target event is processed or not according to the event identification of the target event;
and in response to the target event not being processed, callback the target event from the first event bus for consumption.
5. The method according to claim 1, wherein the method further comprises:
when the event bus corresponding to the target event comprises a second event bus, judging whether the gray configuration information hits to switch gray and judging whether the current time is after the event bus switching instruction triggers;
responding to the gray level configuration information to hit the switching gray level and acquiring an event identifier of the target event after the event switching instruction triggers the current time;
judging whether the target event is processed or not according to the event identification of the target event;
And in response to the target event not being processed, callback the target event from the second event bus for consumption.
6. The method according to claim 1, wherein when the event bus corresponding to the target event includes a first event bus, after determining whether the gradation configuration information hits switching gradation, the method further comprises:
acquiring an event identifier of the target event in response to the gray configuration information not hitting the switching gray;
judging whether the target event is processed or not according to the event identification of the target event;
in response to the target event not being processed, the target event is recalled from the first event bus for processing.
7. The method according to any one of claims 1 to 6, further comprising:
after all the events to be processed are switched from the first event bus to the second event bus for consumption, judging whether the first event bus has an associated event consumption end or not;
if the first event bus does not have the associated event consuming end server, updating the configuration of the event generating end server to cut off a link of reporting the newly generated event to be reported to the first event bus.
8. An event bus switching device, the device comprising:
the gray level configuration acquisition module is used for responding to a consumption request of a target event after the event bus switching instruction is triggered, and acquiring gray level configuration information of the target event;
the event bus determining module is used for determining an event bus corresponding to the target event, and judging whether the gray configuration information hits the switching gray when the event bus corresponding to the target event comprises a first event bus; wherein the switching gray scale is used to control the proportion of events allowed to switch to the second event bus;
the buffer time judging module is used for responding to the gray scale configuration information to hit the switching gray scale and judging whether the current time is within a preset buffer time period or not;
and the target event callback module is used for callback the target event from the first event bus for consumption in response to the current time within the preset buffer time period.
9. A computer device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, characterized in that the processor implements the steps of the method according to any one of claims 1 to 7 when the computer program is executed by the processor.
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 steps of the method of any of claims 1 to 7.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202310804565.4A CN116974782A (en) | 2023-07-03 | 2023-07-03 | Event bus switching method, device, computer equipment and storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202310804565.4A CN116974782A (en) | 2023-07-03 | 2023-07-03 | Event bus switching method, device, computer equipment and storage medium |
Publications (1)
Publication Number | Publication Date |
---|---|
CN116974782A true CN116974782A (en) | 2023-10-31 |
Family
ID=88477550
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202310804565.4A Pending CN116974782A (en) | 2023-07-03 | 2023-07-03 | Event bus switching method, device, computer equipment and storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN116974782A (en) |
-
2023
- 2023-07-03 CN CN202310804565.4A patent/CN116974782A/en active Pending
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN110750267B (en) | Service information updating method, device, computer equipment and storage medium | |
CN111294845B (en) | Node switching method, device, computer equipment and storage medium | |
CN108834086B (en) | Method and device for sending short message, computer equipment and storage medium | |
CN110309109B (en) | Data monitoring method, device, computer equipment and storage medium | |
CN108388478B (en) | Log data processing method and system | |
CN111198921A (en) | Database switching method and device, computer equipment and storage medium | |
CN109460252B (en) | Configuration file processing method and device based on git and computer equipment | |
CN111159233A (en) | Distributed caching method, system, computer device and storage medium | |
CN111966518A (en) | Fault data recording method, system, automobile and storage medium | |
CN108924772B (en) | Short message sending method and device, computer equipment and storage medium | |
CN113724100A (en) | Power grid monitoring alarm message processing method of distributed cluster | |
CN112070585A (en) | Order state unified management method and device, computer equipment and storage medium | |
CN113342284B (en) | Time sequence data storage method and device, computer equipment and storage medium | |
CN112132652B (en) | Order information acquisition method and device, computer equipment and storage medium | |
CN116974782A (en) | Event bus switching method, device, computer equipment and storage medium | |
CN109857344B (en) | Heartbeat state judgment method and device based on shared memory and computer equipment | |
CN111478941B (en) | Mock automatic operation method and device, computer equipment and storage medium | |
CN111934909B (en) | Main-standby machine IP resource switching method, device, computer equipment and storage medium | |
CN110955647A (en) | Database assistance method, database assistance device, computer equipment and storage medium | |
CN113079063A (en) | Offline judgment method, system and device for charging device and computer storage medium | |
CN117056405B (en) | Ship software monitoring data acquisition processing method, system and storage medium | |
CN114615137B (en) | 5G data transmission method and device | |
CN110647526B (en) | Batch data processing method, device, computer equipment and storage medium | |
CN113268348B (en) | Switching method and device of distributed lock server, computer equipment and medium | |
CN111953535B (en) | Network fault positioning method, terminal and storage 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 |