CN116795496A - Event processing method, device, equipment and medium - Google Patents

Event processing method, device, equipment and medium Download PDF

Info

Publication number
CN116795496A
CN116795496A CN202310777722.7A CN202310777722A CN116795496A CN 116795496 A CN116795496 A CN 116795496A CN 202310777722 A CN202310777722 A CN 202310777722A CN 116795496 A CN116795496 A CN 116795496A
Authority
CN
China
Prior art keywords
event
instance
domain
processing
processor
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
CN202310777722.7A
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.)
Hundsun Technologies Inc
Original Assignee
Hundsun Technologies Inc
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 Hundsun Technologies Inc filed Critical Hundsun Technologies Inc
Priority to CN202310777722.7A priority Critical patent/CN116795496A/en
Publication of CN116795496A publication Critical patent/CN116795496A/en
Pending legal-status Critical Current

Links

Abstract

The embodiment of the invention provides an event processing method, device, equipment and medium, relating to the technical field of Internet, wherein the method comprises the following steps: the method comprises the steps of receiving an event instance, determining the event type of the event instance, wherein the event type comprises at least one of intra-domain events and cross-domain events, processing according to a first processing strategy when the event instance belongs to the intra-domain events, wherein the first processing strategy comprises intra-domain processing of the event instance based on an event bus device, and processing according to a second processing strategy when the event instance belongs to the cross-domain events, and the second processing strategy comprises broadcasting the event instance so that the corresponding target event bus device carries out cross-domain processing on the event instance, so that the rationality of event processing is improved.

Description

Event processing method, device, equipment and medium
Technical Field
The present invention relates to the field of internet technologies, and in particular, to an event processing method, apparatus, device, and medium.
Background
Currently, software systems have increasingly complex domain knowledge, and in order to facilitate developers to understand services and improve development efficiency, domain modeling design methods have been gradually popularized in software system design. In the field modeling design, in order to improve the loose coupling and high expansion characteristics of an application program, an event processing framework is also a framework choice for constructing complex applications. Event processing frameworks typically include components such as event handlers, event buses, event stores, etc., which enable the publishing, subscribing, processing, and persistence of events. The event bus is an important component of the framework, allows event publishers and event subscribers in the application program to be loosely coupled in an event mode, completes filtering and distribution of events, and realizes asynchronous collaboration of all parts of the whole system based on the events. However, the event handling rationality of existing event buses remains to be improved.
Disclosure of Invention
One of the objects of the present invention includes, for example, providing an event processing method, apparatus, device and medium to at least partially increase the rationality of event processing.
Embodiments of the invention may be implemented as follows:
in a first aspect, the present invention provides an event processing method applied to an event bus device, the method comprising:
receiving an event instance;
determining an event type of the event instance, the event type including at least one of intra-domain events and cross-domain events;
processing according to a first processing strategy when the event instance belongs to an intra-domain event, wherein the first processing strategy comprises intra-domain processing of the event instance based on the event bus device;
and under the condition that the event instance belongs to a cross-domain event, processing according to a second processing strategy, wherein the second processing strategy comprises broadcasting the event instance so that a corresponding target event bus device carries out cross-domain processing on the event instance.
In an alternative embodiment, the event bus means comprises an event listener, a routing manager, an intra-domain processor, and a cross-domain processor;
The receiving event instance includes: receiving an event instance based on the event listener and sending the event instance to the routing manager;
the determining the event type of the event instance comprises the following steps: determining an event type of the event instance based on the event instance received by the routing manager;
the processing according to the first processing policy in the case that the event instance belongs to an intra-domain event includes: generating an event instance processing instruction and sending the event instance processing instruction to the intra-domain processor based on the routing manager under the condition that the event instance belongs to an intra-domain event, and routing the event instance to a corresponding intra-domain event processor for processing based on the intra-domain processor;
and processing according to a second processing strategy under the condition that the event instance belongs to a cross-domain event, wherein the processing comprises the following steps: based on the route manager, generating an event instance processing instruction and sending the event instance processing instruction to the cross-domain processor under the condition that the event instance belongs to a cross-domain event, generating an event instance transmission instruction according to the event instance processing instruction based on the cross-domain processor, and broadcasting the event instance transmission instruction to a multicast network so that a target cross-domain processor corresponding to the event instance transmission instruction processes the event instance.
In an alternative embodiment, the method further comprises:
under the condition that the cross-domain processor receives event instance transmission instructions broadcast by other cross-domain processors in the multicast network, determining whether the cross-domain processor is a target cross-domain processor corresponding to the event instance transmission instructions;
if yes, processing the event instance transmission instruction;
if not, discarding the event instance transmission instruction.
In an alternative embodiment, the event instance includes an event type identifier, the routing manager pre-stores an intra-domain routing mapping table and a cross-domain routing mapping table, the determining, based on the event instance received by the routing manager, an event type of the event instance includes:
according to the event type identification of the event instance, searching the intra-domain routing mapping table, determining whether a locally available event processor exists, if so, determining that the event instance belongs to an intra-domain event;
and according to the event type identification of the event instance, searching the cross-domain routing mapping table, determining whether a cross-domain available event processor exists, and if the cross-domain available event processor exists, determining that the event instance belongs to a cross-domain event.
In an alternative embodiment, the event instance further includes an event instance identification and an event instance parameter; the event instance processing instruction comprises an event instance identifier, an event type identifier, an event instance parameter and an event processing target identifier;
the generating an event instance transmission instruction according to the event instance processing instruction comprises the following steps:
acquiring a specific event type according to the event type identifier in the event instance processing instruction;
serializing event instance parameters in the event instance processing instruction;
generating an event instance transmission instruction based on the event instance, the specific event type and the serialized event instance parameters, wherein the event instance transmission instruction comprises an event instance identifier, an event type identifier, event instance parameter content and a first event processing target identifier;
wherein the event instance identifier is used for uniquely specifying an identifier of an event instance; the event type identification is used for describing the event type processed by the event processor; the event instance parameters are used for storing specific parameter information of event instances; the event processing target identification is used for describing a specific processing target of an event, and the event processing target identification is filled by using an event processor identification; the event instance parameter content is used for storing the serialization result of the specific parameters of the event instance; the first event processing target identifier is used for designating an application instance identifier for processing the event.
In an alternative embodiment, the broadcasting the event instance transmission instruction to a multicast network, so that a target cross-domain processor corresponding to the event instance transmission instruction processes the event instance, including:
broadcasting the event instance transmission instruction to a multicast network;
determining whether a first event processing target identifier in the event instance transmission instruction is matched with a local application instance identifier based on a cross-domain processor which receives the event instance transmission instruction;
if so, determining the self as a target cross-domain processor corresponding to the event instance transmission instruction, acquiring a specific event type according to an event type identifier in the event instance transmission instruction, de-serializing event instance parameter content in the event instance transmission instruction into event instance parameters, retrieving an intra-domain routing mapping table of the routing manager through the event type identifier in the event instance transmission instruction, acquiring a local event processor available for processing, generating an event instance processing instruction, and sending the event instance processing instruction to the event processor for processing.
In an alternative embodiment, the event bus device further includes a registrar and a cross-domain coordinator, and the method further includes a step of registering information in the multicast network based on the registrar, the step including:
When a domain service application to which the event bus device belongs is started, scanning all declared event meta-information and event processor meta-information in the domain service application, finishing event type and event processor registration based on the registrar, scanning the domain service application configuration, retrieving an application local instance identifier, and generating an event processor registration instruction; the event meta-information comprises an event type identifier and an event type, and the event processor meta-information comprises an event processor type identifier, an event type identifier and event processor local inlet information;
based on the registrar, sending the event meta-information and event processor meta-information to the routing manager, and sending the event processor registration instruction to the cross-domain coordinator, and based on the cross-domain coordinator, broadcasting the event processor registration instruction to a multicast network;
creating an intra-domain routing mapping table of an event type identifier corresponding to an event processor identifier set based on the event meta-information and the event processor meta-information received by the routing manager;
and based on the routing manager receiving an event processor registration instruction sent by the cross-domain coordinator, creating a cross-domain routing mapping table of an event type identifier corresponding to an application instance identifier set.
In a second aspect, an embodiment of the present invention provides an event processing apparatus, which is applied to an event bus apparatus, where the event processing apparatus includes an information obtaining module and an information processing module;
the information acquisition module is used for receiving event instances;
the information processing module is used for determining an event type of the event instance, the event type comprises at least one of intra-domain events and cross-domain events, and when the event instance belongs to the intra-domain events, the event instance is processed according to a first processing strategy, and the first processing strategy comprises intra-domain processing of the event instance based on the event bus device; and under the condition that the event instance belongs to a cross-domain event, processing according to a second processing strategy, wherein the second processing strategy comprises broadcasting the event instance so that a corresponding target event bus device carries out cross-domain processing on the event instance.
In an alternative embodiment, the event bus means comprises an event listener, a routing manager, an intra-domain processor, and a cross-domain processor;
the information obtaining module is used for receiving an event instance based on the event monitor and sending the event instance to the routing manager;
The information processing module is used for receiving an event instance based on the routing manager, determining the event type of the event instance, generating an event instance processing instruction and sending the event instance processing instruction to the intra-domain processor under the condition that the event instance belongs to an intra-domain event, and routing the event instance to the corresponding intra-domain event processor for processing based on the intra-domain processor; and under the condition that the event instance belongs to a cross-domain event, generating an event instance processing instruction, sending the event instance processing instruction to the cross-domain processor, generating an event instance transmission instruction according to the event instance processing instruction based on the cross-domain processor, and broadcasting the event instance transmission instruction to a multicast network so as to enable a target cross-domain processor corresponding to the event instance transmission instruction to process the event instance.
In a third aspect, the present invention provides an electronic device comprising: a memory, a processor and a computer program stored on the memory and executable on the processor, the processor implementing the event processing method of any of the preceding embodiments when the program is executed.
In a fourth aspect, the present invention provides a computer readable storage medium, where the computer readable storage medium includes a computer program, where the computer program controls an electronic device where the computer readable storage medium is located to execute the event processing method according to any one of the foregoing embodiments.
The beneficial effects of the embodiment of the invention include, for example: through ingenious design of the event bus device, reliable integration of intra-domain event routing and cross-domain event routing is achieved, so that reliable processing of intra-domain events and cross-domain events is achieved, and the rationality of event processing is improved.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings that are needed in the embodiments will be briefly described below, it being understood that the following drawings only illustrate some embodiments of the present invention and therefore should not be considered as limiting the scope, and other related drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
Fig. 1 shows an application scenario schematic diagram provided by an embodiment of the present invention.
Fig. 2 shows a flow chart of an event processing method according to an embodiment of the present invention.
Fig. 3 is a schematic structural diagram of an event bus device according to an embodiment of the present invention.
Fig. 4 is another flow chart of an event processing method according to an embodiment of the present invention.
Fig. 5 shows an interaction architecture diagram of an event bus device according to an embodiment of the present invention.
Fig. 6 is another flow chart of an event processing method according to an embodiment of the present invention.
Fig. 7 is a functional block diagram of an event bus device according to an embodiment of the present invention.
Icon: 100-an electronic device; 110-memory; a 120-processor; 130-a communication module; 140-event processing means; 141-an information obtaining module; 142-information processing module.
Detailed Description
Today, domain modeling designs can segment complex applications into multiple loosely coupled microservices, each microservice application (also called a domain service application, a domain service process in this embodiment) can run in an independent process, which puts forward two scenarios of event routing for an event bus: in each micro-service process, event routing between intra-domain models; event routing between microservices, and between cross-domain models. At present, the routing capability of the two types of events can be realized through a simple event bus and a distributed event bus which can obtain single responsibility through an event processing Framework such as an Axon Framework and the like.
It has been found that the implementation has the following problems:
1. if the simple event bus is used alone, the events can only be distributed in the process, and event messages can be interacted between the intra-domain models at high speed through the memory, but the event collaboration can not be realized with the external-domain models.
2. If the distributed event bus is used alone, when the application runs, a large number of intra-domain events are distributed through the distributed event bus, so that network resources are rapidly consumed, and meanwhile, the original memory-level event interaction is converted into network interaction, so that the event distribution efficiency is reduced. Whereas model events actually used for cross-domain collaboration often account for only a very small portion of the total events applied (high cohesion of micro services, loosely coupled nature controls the number of interactions between cross-domain services).
3. If the simple event bus and the distributed event bus are introduced into the application at the same time, the application development is faced, the use of two sets of event buses is required to be continuously switched in the development process, the development efficiency is reduced, and the probability of development errors is increased.
Based on the above research, the embodiment of the invention provides an event processing scheme, which can realize unified processing of intra-domain event routing and cross-domain event routing through ingenious configuration of an event processing device, thereby improving the rationality of event processing.
The present invention is directed to a method for manufacturing a semiconductor device, and a semiconductor device manufactured by the method.
For the purpose of making the objects, technical solutions and advantages of the embodiments of the present invention more apparent, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention, and it is apparent that the described embodiments are some embodiments of the present invention, but not all embodiments of the present invention. The components of the embodiments of the present invention generally described and illustrated in the figures herein may be arranged and designed in a wide variety of different configurations.
Thus, the following detailed description of the embodiments of the invention, as presented in the figures, is not intended to limit the scope of the invention, as claimed, but is merely representative of selected embodiments of the invention. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention.
It should be noted that the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one … …" does not exclude the presence of other like elements in a process, method, article, or apparatus that comprises the element.
It should be noted that: like reference numerals and letters denote like items in the following figures, and thus once an item is defined in one figure, no further definition or explanation thereof is necessary in the following figures.
It should be noted that the features of the embodiments of the present invention may be combined with each other without conflict.
Fig. 1 is a block diagram of an electronic device 100 according to the present embodiment, where the electronic device 100 in the present embodiment may be a server, a processing device, a processing platform, etc. capable of performing data interaction and processing. For example, it may be a device in an event processing framework for implementing an event bus arrangement.
The electronic device 100 includes a memory 110, a processor 120, and a communication module 130. The memory 110, the processor 120, and the communication module 130 are electrically connected directly or indirectly to each other to realize data transmission or interaction. For example, the components may be electrically connected to each other via one or more communication buses or signal lines.
Wherein the memory 110 is used for storing programs or data. The Memory 110 may be, but is not limited to, random access Memory (Random Access Memory, RAM), read Only Memory (ROM), programmable Read Only Memory (Programmable Read-Only Memory, PROM), erasable Read Only Memory (Erasable Programmable Read-Only Memory, EPROM), electrically erasable Read Only Memory (Electric Erasable Programmable Read-Only Memory, EEPROM), etc.
The processor 120 is used to read/write data or programs stored in the memory 110 and perform corresponding functions.
The communication module 130 is configured to establish a communication connection between the electronic device 100 and other communication terminals through the network, and is configured to transmit and receive data through the network.
It should be understood that the structure shown in fig. 1 is merely a schematic diagram of the structure of the electronic device 100, and that the electronic device 100 may further include more or fewer components than those shown in fig. 1, or have a different configuration than that shown in fig. 1. The components shown in fig. 1 may be implemented in hardware, software, or a combination thereof.
Referring to fig. 2 in combination, a flowchart of an event processing method according to an embodiment of the invention may be executed by the electronic device 100 shown in fig. 1, for example, may be executed by the processor 120 in the electronic device 100. The event processing method includes S110, S120, and S130.
S110, receiving event instances.
S120, determining an event type of the event instance, wherein the event type comprises at least one of intra-domain events and cross-domain events.
S130, processing according to a first processing strategy when the event instance belongs to an intra-domain event, wherein the first processing strategy comprises intra-domain processing of the event instance based on the event bus device; and under the condition that the event instance belongs to a cross-domain event, processing according to a second processing strategy, wherein the second processing strategy comprises broadcasting the event instance so that a corresponding target event bus device carries out cross-domain processing on the event instance.
Through the process, the reliable processing of the intra-domain event and the cross-domain event is realized, the intra-domain event and the cross-domain event are divided by the event instance, and the intra-domain event and the cross-domain event are processed according to the adaptive processing strategy respectively, so that the rationality of event processing is improved.
In this embodiment, the implementation architecture of the event bus device may be flexibly selected, so long as the process shown in fig. 2 can reliably process intra-domain events and cross-domain events.
Referring to fig. 3 in combination, a schematic structure diagram of an event bus device according to an embodiment of the present invention is provided, and the event bus device in this embodiment may be implemented based on the electronic device shown in fig. 1. The event bus arrangement may include an event listener, a routing manager, an intra-domain processor, and a cross-domain processor.
Referring to fig. 4 in combination with fig. 3, another flow chart of an event processing method according to an embodiment of the invention is shown. The event processing method includes S210, S220, S230, and S240.
S210, receiving an event instance based on the event monitor and sending the event instance to the routing manager.
S220, based on the event instance received by the routing manager, determining the event type of the event instance, and generating an event instance processing instruction and sending the event instance processing instruction to the intra-domain processor under the condition that the event instance belongs to the intra-domain event; and generating an event instance processing instruction and sending the event instance processing instruction to the cross-domain processor under the condition that the event instance belongs to the cross-domain event.
And S230, based on the intra-domain processor, the event instance is routed to the corresponding intra-domain event processor for processing.
S240, based on the cross-domain processor, generating an event instance transmission instruction according to the event instance processing instruction, and broadcasting the event instance transmission instruction to a multicast network, so that a target cross-domain processor corresponding to the event instance transmission instruction processes the event instance.
By designing the event bus device as an integrated event monitor, a routing manager, an intra-domain processor and a cross-domain processor, the co-processing of intra-domain events and cross-domain events is realized, the flexibility is higher, and the efficiency and the reliability of event processing are improved.
In S210, the event instance may be from a domain model in a domain service application, and accordingly, receiving, based on the event listener, the event instance may include: and receiving event instances sent by the domain model in the domain service application based on the event monitor.
Illustratively, if a domain a service application includes the event bus device and the domain a model shown in fig. 3 in this embodiment, in S210, an event instance sent by the domain a model in the domain a service application may be received based on the event listener.
The event monitor monitors all events in the domain service application, and routes the monitored events to the routing manager for event routing.
In S220, based on the event instance received by the routing manager, the event instance may be from a domain model in a domain service application, and the event instance may be monitored by the event monitor and sent to the routing manager, or may be from another domain service application. Correspondingly, after receiving the event instance, the routing manager judges the type of the event instance.
For example, event instances may correspond to domain service applications (domains), may correspond to other domain service applications (cross-domains), and may belong to both domain service applications (domains) and other domain service applications (cross-domains).
Event instances corresponding to the domain service applications are sent to the intra-domain processor, and event instances corresponding to other domain service applications are sent to the cross-domain processor. Event instances corresponding to both the domain service application and other domain service applications are sent to both the domain processor and the cross-domain processor.
The routing manager may pre-configure the correspondence between each data and each device, for example, the correspondence between each data and each device may be defined by a unique identifier. The routing manager thereby sends event instance processing instructions to at least one of the intra-domain processor and the cross-domain processor based on the preconfigured decisions.
By way of example, event instances may include event type identifications, and intra-domain and cross-domain routing maps may be pre-stored in the routing manager. The routing manager provides event routing instructions for the cross-domain processor and the intra-domain processor by maintaining a routing mapping table.
In S220, the intra-domain routing mapping table may be searched according to the event type identifier of the event instance, to determine whether there is a locally available event processor, and if so, an event instance processing instruction is generated and sent to the intra-domain processor. And according to the event type identification of the event instance, retrieving the cross-domain routing mapping table, determining whether a cross-domain available event processor exists, and if the cross-domain available event processor exists, generating an event instance processing instruction and sending the event instance processing instruction to the cross-domain processor.
The domain routing mapping table is retrieved according to the event type identifier of the event instance, and the cross-domain routing mapping table is retrieved according to the event type identifier of the event instance, and may be executed synchronously or sequentially. Illustratively, to increase event processing efficiency as much as possible, the intra-domain routing mapping table and the cross-domain routing mapping table may be retrieved synchronously. In order to save processing resources as much as possible, the method may be performed sequentially, for example, retrieving the intra-domain routing mapping table first and then retrieving the cross-domain routing mapping table, which is not limited in this embodiment.
In the case that the event instance processing instruction is sent to the intra-domain processor and/or the cross-domain processor, the intra-domain processor in S230 is configured to receive all intra-domain events and route the intra-domain events to the corresponding intra-domain event processor, so as to complete intra-domain event processing. The cross-domain processor in S240 is configured to distribute and receive a cross-domain event, filter the received cross-domain event, and send the filtered cross-domain event to a corresponding intra-domain processor, so as to complete event processing. Thereby completing the reliable processing of intra-domain events and cross-domain events.
In an exemplary case, when a cross-domain event to be distributed is received, the cross-domain processor generates an event instance transmission instruction according to an event instance processing instruction of the cross-domain event and broadcasts the event instance transmission instruction to a multicast network. Under the condition that event instance transmission instructions broadcast by other cross-domain processors in the multicast network are received, each cross-domain processor determines whether the event instance transmission instruction is a target cross-domain processor corresponding to the event instance transmission instruction, if so, the event instance transmission instruction is distributed to the intra-domain processor in the event bus device where the event instance transmission instruction is located, so that event processing is completed. If not, discarding the event instance transmission instruction.
In the present embodiment, S230 and S240 are not intended to limit the execution sequence, and according to the processing result of S220, S230 and S240 may execute only one step, or may execute both steps simultaneously.
Referring to fig. 5 in combination, to further improve the reliability and rationality of event processing, the event bus arrangement may further include a registrar and a cross-domain coordinator. Wherein the registrar is responsible for registering all event types and event handlers declared in the domain. The cross-domain coordinator is used to distribute registered event types and event handlers among different domains.
Based on the registrar, registration of information in the multicast network may be achieved by: scanning all declared event meta-information and event processor meta-information in the domain service application when the domain service application to which the event bus device belongs is started, and finishing event type and event processor registration based on the registrar; and scanning the domain service application configuration, retrieving the application local instance identifier and generating an event processor registration instruction. The event meta-information comprises an event type identifier and an event type, the event processor meta-information comprises an event processor type identifier, an event type identifier and event processor local inlet information, and the event processor registration instruction comprises an event processor type identifier, an event type identifier and an application instance identifier.
And transmitting the event meta information and the event processor meta information to the routing manager based on the registrar, transmitting the event processor registration instruction to the cross-domain coordinator, and broadcasting the event processor registration instruction to a multicast network based on the cross-domain coordinator. Thereby creating an intra-domain routing mapping table for event type identification corresponding to the event handler identification set based on the event meta-information and event handler meta-information received by the routing manager. And based on the routing manager receiving an event processor registration instruction sent by the cross-domain coordinator, creating a cross-domain routing mapping table of an event type identifier corresponding to an application instance identifier set.
In this embodiment, the content included in the event instance, the event instance processing instruction, the event instance transmission instruction, and the like may have various forms as long as the event processing can be reliably realized. For example, in one implementation, an event instance may include an event type identification, an event instance identification, and an event instance parameter. The event instance processing instructions may include an event instance identification, an event type identification, an event instance parameter, and an event processing target identification.
Accordingly, referring to fig. 6 in combination, generating an event instance transmission instruction according to the event instance processing instruction may be implemented through S241, S242, and S243.
S241, acquiring a specific event type according to the event type identification in the event instance processing instruction.
S242, the event instance parameters in the event instance processing instruction are serialized.
S243, generating an event instance transmission instruction based on the event instance, the specific event type and the serialized event instance parameters.
The event instance transmission instructions include an event instance identification, an event type identification, event instance parameter content, and a first event processing target identification.
Wherein the event instance identifier is used for uniquely specifying an identifier of an event instance; the event type identification is used for describing the event type processed by the event processor; the event instance parameters are used for storing specific parameter information of event instances; the event processing target identification is used for describing a specific processing target of an event, and the event processing target identification is filled by using an event processor identification; the event instance parameter content is used for storing the serialization result of the specific parameters of the event instance; the first event processing target identifier is used for designating an application instance identifier for processing the event.
Accordingly, broadcasting the event instance transmission instruction to a multicast network, so that the target cross-domain processor corresponding to the event instance transmission instruction processes the event instance, which can be realized by the following steps: broadcasting the event instance transmission instruction to a multicast network, and determining whether a first event processing target identifier in the event instance transmission instruction is matched with a local application instance identifier based on a cross-domain processor receiving the event instance transmission instruction. If so, determining the self as a target cross-domain processor corresponding to the event instance transmission instruction, acquiring a specific event type according to an event type identifier in the event instance transmission instruction, de-serializing event instance parameter content in the event instance transmission instruction into event instance parameters, retrieving an intra-domain routing mapping table of the routing manager through the event type identifier in the event instance transmission instruction, acquiring a local event processor available for processing, generating an event instance processing instruction, and sending the event instance processing instruction to the event processor for processing.
In order to more clearly illustrate the event processing scheme in the present application, the following scenario is taken as an example to illustrate the overall configuration and implementation principles of the event bus device.
With continued reference to fig. 5, the event bus apparatus in this embodiment includes a register, a cross-domain coordinator, a routing manager, a cross-domain processor, an intra-domain processor, and an event listener.
A register: for all event types and event handlers that are responsible for registering declarations within the domain.
A cross-domain coordinator: for distributing registered event types and event handlers among different domains.
Event listener: the method is used for monitoring all events in the field and routing the monitored events to a routing manager for event routing.
Route manager: the system is used for maintaining an event routing table and providing event routing instructions for the cross-domain processor and the intra-domain processor.
Cross-domain processor: the method is used for distributing and receiving the cross-domain event, and simultaneously filtering the received cross-domain event and sending the filtered cross-domain event to the intra-domain processor.
An intra-domain processor: for receiving all intra-domain events and routing the intra-domain events to the corresponding intra-domain event handler.
Based on the above architecture, the following configuration is performed for the domain service application:
event declarations and event handler declarations are made in advance, and all event meta-information related in the art is declared through notes or configuration, the event meta-information including the following:
Event type identification (event_id): within the universe, event type identification is used to uniquely define an event type.
Event type (event_type): type information describing the event (e.g., class path defined by the event type) is used to implement serialization and de-serialization processes for the event.
Event description (event_description): for describing event-related specifications.
All event handler meta-information referred to in the art is declared by annotation or configuration, which contains the following:
event handler type identification (handler_id): within the universe, event handler type identification is used to uniquely define an event handler type.
Event type identification (event_id): for describing the type of event that the event handler is handling.
Event processor local entry information (handler_target): for declaring the local program entry address (e.g., class path and method name for processor implementation) corresponding to the event handler.
Application local instance identification (application_name) in the art is declared by configuration.
Based on the configuration, when the domain service application is started, all the declared event meta-information and event processor meta-information in the application are scanned, so that event registration and event processor registration are completed, and the registration flow is as follows:
When the domain service application is started, the registrar searches the event meta-information of all declarations in the application by scanning the notes or configuration, and generates an event meta-information description list. The list comprises a Map mapping table composed of event type identifiers and corresponding event meta-information.
When the domain service application is started, the registrar searches the meta information of all the event processors stated in the application by scanning the notes or configuration, and generates a meta information description list of the event processors. The list comprises a Map mapping table composed of event processor identifications and corresponding event processor meta-information.
When the domain service application is started, the registrar searches the application local instance identifier by scanning the application configuration. Meanwhile, according to the generated meta-information description list of the event processor, generating an event processor registration instruction, wherein the instruction comprises the following contents:
event handler type identification (handler_id): within the universe, event handler type identification is used to uniquely define an event handler type.
Event type identification (event_id): for describing the type of event that the event handler is handling.
Application instance identification (application_name) for describing the application instance to which the processor belongs.
The registrar sends the generated event meta-information description list and the generated event processor meta-information description list to the route manager, and sends the generated event processor registration instruction to the cross-domain coordinator.
The cross-domain coordinator receives an event processor registration instruction sent by the registrar and broadcasts the instruction to the multicast network. Meanwhile, the cross-domain coordinator receives event processor registration instructions broadcast by other application nodes of the multicast network and sends the instructions to the routing manager.
The routing manager receives the event meta-information description list sent by the registrar and the event processor meta-information description list. A local (intra-domain) routing mapping table is created for the set of event type identifications corresponding to the event handler identifications. The following table shows:
event_1 [handler_a]
event_2 [handler_b,handler_c]
event_3 [handler_d]
the routing manager receives an event processor registration instruction sent by the cross-domain coordinator and creates a cross-domain routing mapping table of an event type identifier corresponding to an application instance identifier set. The following table shows:
event_1 [application_A]
event_2 [application_B]
event_3 []
during the running of the application, the domain model in the application issues a specific event instance, the event routing is performed through an event bus, and the event instance is sent to a corresponding event processor for processing.
The event listener receives specific event instances issued by the domain model in the application. Examples of events include the following:
Event instance identification (instance_id): for uniquely specifying the identity of an event instance.
Event type identification (event_id): for describing the type of event that the event handler is handling.
Event instance parameters (parameters): for storing specific parameter information for the instance event.
The event listener sends the received event instance to the routing manager.
The routing manager receives event instances sent by the event monitor and obtains event type identifiers from the event instances.
The routing manager searches the local routing mapping table through the event type identification, and if a local event processor set available for processing exists, an event instance processing instruction is generated and sent to the intra-domain processor. The event instance processing instructions include the following:
event instance identification (instance_id): for uniquely specifying the identity of an event instance.
Event type identification (event_id): for describing the type of event that the event handler is handling.
Event instance parameters (parameters): for storing specific parameter information for the instance event.
Event processing target identification (target_id): for describing the specific processing objective of the event. The event processor identity is used here to populate the event processing target identity.
The routing manager searches the cross-domain routing mapping table through the event type identification, and if an application instance identification set which can be used for event processing in a cross-domain mode exists, an event instance processing instruction is generated and sent to the cross-domain processor. The event instance processing instruction content is as follows:
event instance identification (instance_id): for uniquely specifying the identity of an event instance.
Event type identification (event_id): for describing the type of event that the event handler is handling.
Event instance parameters (parameters): for storing specific parameter information for the instance event.
Event processing target identification (target_id): for describing the specific processing objective of the event. The event processing target identity is populated here with application instance identities.
The cross-domain processor receives an event instance processing instruction sent by the routing manager, acquires a specific event type (event_type) according to the event type identifier, sequences event instance parameters to generate an event instance transmission instruction, and broadcasts the instruction into the multicast network. The event instance transmission instruction includes the following:
event instance identification (instance_id): for uniquely specifying the identity of an event instance.
Event type identification (event_id): for describing the type of event that the event handler is handling.
Event instance parameter content (parameters_message): for storing the serialized results of the specific parameters of the instance event.
Event processing target identification (target_id): application instance identification for handling the event.
The cross-domain processor receives event instance transmission instructions broadcast by other application nodes in the multicast network, if the event processing target identification of the instructions is equal to the application local instance identification, the cross-domain processor acquires a specific event type event_type according to the event type identification), and then de-sequences the event instance parameter content in the event instance transmission instructions into event instance parameters. And retrieving a local routing mapping table of the routing manager through the event type identification of the instruction, acquiring a local event processor set available for processing, generating an event instance processing instruction and transmitting the event instance processing instruction to the intra-domain processor. If the event processing target identification of the instruction is not equal to the application local instance identification, the intra-domain processor receives the event instance processing instruction sent by the routing manager and the cross-domain processor, acquires the local entry information of the event processor through the event processor identification, and sends the event to a specific class and a method for processing locally, so that final event routing is realized.
Based on the event processing method, the intra-domain event routing and cross-domain event routing capabilities in the prior art practice are integrated on a unified event bus device, the event type and the meta-information of an event processor are acquired through automatic scanning when the application is started, and the meta-information is broadcast and distributed in each application node through a multicast network, so that unified registration of each application node is realized. During the running of the system, different event routing strategies can be automatically realized according to the cross-domain routing mapping table and the local routing mapping table which are uniformly registered in the routing manager. Because the number of the cross-domain events is controllable, the event type of the event processor registered by the external application does not enter the cross-domain event transmission, and the consumption of network resources is greatly reduced. Cross-domain events are broadcast through a multicast network, and non-home domain events can be filtered at an entrance, so that the processing performance is high. And the intra-domain events are directly distributed through the memory local routing mapping table, so that the processing efficiency of the intra-domain events is ensured. When a developer of the field model develops service logic, the developer only needs to face one event bus device, and the specific processing of the event can be realized, so that the developer is free of sense, the development efficiency is improved, the risk of system errors is reduced, and the rationality and reliability of event processing are ensured.
In order to perform the respective steps of the above embodiments and of the various possible ways, an implementation of an event processing device is given below. Referring to fig. 7, fig. 7 is a functional block diagram of an event processing device 140 according to an embodiment of the invention, where the event processing device 140 can be applied to the electronic apparatus for implementing the event bus device shown in fig. 1. It should be noted that, the basic principle and the technical effects of the event processing device 140 provided in this embodiment are the same as those of the above-mentioned method embodiment, and for brevity, reference should be made to the corresponding content in the above-mentioned method embodiment for the description of this embodiment. The event processing apparatus 140 includes an information obtaining module 141 and an information processing module 142.
Wherein the information obtaining module 141 is configured to receive an event instance.
The information processing module 142 is configured to determine an event type of the event instance, where the event type includes at least one of a intra-domain event and a cross-domain event, and where the event instance belongs to the intra-domain event, perform processing according to a first processing policy, where the first processing policy includes intra-domain processing on the event instance based on the event bus device; and under the condition that the event instance belongs to a cross-domain event, processing according to a second processing strategy, wherein the second processing strategy comprises broadcasting the event instance so that a corresponding target event bus device carries out cross-domain processing on the event instance.
In the case that the event bus apparatus includes an event listener, a routing manager, an intra-domain processor, and a cross-domain processor, the information obtaining module 141 is configured to receive an event instance based on the event listener and transmit the event instance to the routing manager.
The information processing module 142 is configured to determine an event type of the event instance based on the event instance received by the routing manager, generate an event instance processing instruction and send the event instance processing instruction to the intra-domain processor when the event instance belongs to an intra-domain event, and route the event instance to a corresponding intra-domain event processor for processing based on the intra-domain processor; and under the condition that the event instance belongs to a cross-domain event, generating an event instance processing instruction, sending the event instance processing instruction to the cross-domain processor, generating an event instance transmission instruction according to the event instance processing instruction based on the cross-domain processor, and broadcasting the event instance transmission instruction to a multicast network so as to enable a target cross-domain processor corresponding to the event instance transmission instruction to process the event instance.
On the basis of the above, the embodiment of the invention also provides a computer readable storage medium, which comprises a computer program, and when the computer program runs, the electronic equipment where the computer readable storage medium is located is controlled to execute the event processing method.
By adopting the scheme in the embodiment of the invention, the event classification meta-information can be maintained, the intelligent identification of the intra-domain events and the cross-domain events is realized, the network pressure of the cross-domain event interaction is reduced, the high-performance routing of the events under the distributed type is realized, the model developer can realize the release and subscription of the events only by facing one unified event bus, and the rationality and the reliability of the event processing are improved.
In the several embodiments provided in the present invention, it should be understood that the disclosed apparatus and method may be implemented in other manners. The apparatus embodiments described above are merely illustrative, for example, of the flowcharts and block diagrams in the figures that illustrate the architecture, functionality, and operation of possible implementations of apparatus, methods and computer program products according to various embodiments of the present invention. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that 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.
In addition, functional modules in the embodiments of the present invention may be integrated together to form a single part, or each module may exist alone, or two or more modules may be integrated to form a single part.
The functions, if implemented in the form of software functional modules and sold or used as a stand-alone product, may be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention may be embodied essentially or in a part contributing to the prior art or in a part of the technical solution, in the form of a software product stored in a storage medium, comprising several instructions for causing a computer device (which may be a personal computer, a server, a network device, etc.) to perform all or part of the steps of the method according to the embodiments of the present invention. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a random access Memory (RAM, random Access Memory), a magnetic disk, or an optical disk, or other various media capable of storing program codes.
The above description is only of the preferred embodiments of the present invention and is not intended to limit the present invention, but various modifications and variations can be made to the present invention by those skilled in the art. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention should be included in the protection scope of the present invention.

Claims (11)

1. An event processing method, applied to an event bus device, comprising:
receiving an event instance;
determining an event type of the event instance, the event type including at least one of intra-domain events and cross-domain events;
processing according to a first processing strategy when the event instance belongs to an intra-domain event, wherein the first processing strategy comprises intra-domain processing of the event instance based on the event bus device;
and under the condition that the event instance belongs to a cross-domain event, processing according to a second processing strategy, wherein the second processing strategy comprises broadcasting the event instance so that a corresponding target event bus device carries out cross-domain processing on the event instance.
2. The event processing method according to claim 1, wherein the event bus means comprises an event listener, a routing manager, an intra-domain processor, and a cross-domain processor;
the receiving event instance includes: receiving an event instance based on the event listener and sending the event instance to the routing manager;
the determining the event type of the event instance comprises the following steps: determining an event type of the event instance based on the event instance received by the routing manager;
The processing according to the first processing policy in the case that the event instance belongs to an intra-domain event includes: generating an event instance processing instruction and sending the event instance processing instruction to the intra-domain processor based on the routing manager under the condition that the event instance belongs to an intra-domain event, and routing the event instance to a corresponding intra-domain event processor for processing based on the intra-domain processor;
and processing according to a second processing strategy under the condition that the event instance belongs to a cross-domain event, wherein the processing comprises the following steps: based on the route manager, generating an event instance processing instruction and sending the event instance processing instruction to the cross-domain processor under the condition that the event instance belongs to a cross-domain event, generating an event instance transmission instruction according to the event instance processing instruction based on the cross-domain processor, and broadcasting the event instance transmission instruction to a multicast network so that a target cross-domain processor corresponding to the event instance transmission instruction processes the event instance.
3. The event processing method according to claim 2, characterized in that the method further comprises:
under the condition that the cross-domain processor receives event instance transmission instructions broadcast by other cross-domain processors in the multicast network, determining whether the cross-domain processor is a target cross-domain processor corresponding to the event instance transmission instructions;
If yes, processing the event instance transmission instruction;
if not, discarding the event instance transmission instruction.
4. The event processing method according to claim 2, wherein the event instance includes an event type identifier, the routing manager pre-stores an intra-domain routing mapping table and a cross-domain routing mapping table, the determining the event type of the event instance based on the event instance received by the routing manager includes:
according to the event type identification of the event instance, searching the intra-domain routing mapping table, determining whether a locally available event processor exists, if so, determining that the event instance belongs to an intra-domain event;
and according to the event type identification of the event instance, searching the cross-domain routing mapping table, determining whether a cross-domain available event processor exists, and if the cross-domain available event processor exists, determining that the event instance belongs to a cross-domain event.
5. The event processing method of claim 4, wherein the event instance further comprises an event instance identification and an event instance parameter; the event instance processing instruction comprises an event instance identifier, an event type identifier, an event instance parameter and an event processing target identifier;
The generating an event instance transmission instruction according to the event instance processing instruction comprises the following steps:
acquiring a specific event type according to the event type identifier in the event instance processing instruction;
serializing event instance parameters in the event instance processing instruction;
generating an event instance transmission instruction based on the event instance, the specific event type and the serialized event instance parameters, wherein the event instance transmission instruction comprises an event instance identifier, an event type identifier, event instance parameter content and a first event processing target identifier;
wherein the event instance identifier is used for uniquely specifying an identifier of an event instance; the event type identification is used for describing the event type processed by the event processor; the event instance parameters are used for storing specific parameter information of event instances; the event processing target identification is used for describing a specific processing target of an event, and the event processing target identification is filled by using an event processor identification; the event instance parameter content is used for storing the serialization result of the specific parameters of the event instance; the first event processing target identifier is used for designating an application instance identifier for processing the event.
6. The event processing method according to claim 5, wherein broadcasting the event instance transmission instruction into a multicast network to cause a target cross-domain processor corresponding to the event instance transmission instruction to process the event instance, comprises:
broadcasting the event instance transmission instruction to a multicast network;
determining whether a first event processing target identifier in the event instance transmission instruction is matched with a local application instance identifier based on a cross-domain processor which receives the event instance transmission instruction;
if so, determining the self as a target cross-domain processor corresponding to the event instance transmission instruction, acquiring a specific event type according to an event type identifier in the event instance transmission instruction, de-serializing event instance parameter content in the event instance transmission instruction into event instance parameters, retrieving an intra-domain routing mapping table of the routing manager through the event type identifier in the event instance transmission instruction, acquiring a local event processor available for processing, generating an event instance processing instruction, and sending the event instance processing instruction to the event processor for processing.
7. The event processing method according to any one of claims 2 to 6, wherein the event bus device further comprises a registrar and a cross-domain coordinator, the method further comprising the step of registering information in the multicast network based on the registrar, the step comprising:
When a domain service application to which the event bus device belongs is started, scanning all declared event meta-information and event processor meta-information in the domain service application, finishing event type and event processor registration based on the registrar, scanning the domain service application configuration, retrieving an application local instance identifier, and generating an event processor registration instruction; the event meta-information comprises an event type identifier and an event type, and the event processor meta-information comprises an event processor type identifier, an event type identifier and event processor local inlet information;
based on the registrar, sending the event meta-information and event processor meta-information to the routing manager, and sending the event processor registration instruction to the cross-domain coordinator, and based on the cross-domain coordinator, broadcasting the event processor registration instruction to a multicast network;
creating an intra-domain routing mapping table of an event type identifier corresponding to an event processor identifier set based on the event meta-information and the event processor meta-information received by the routing manager;
and based on the routing manager receiving an event processor registration instruction sent by the cross-domain coordinator, creating a cross-domain routing mapping table of an event type identifier corresponding to an application instance identifier set.
8. An event processing device, characterized in that it is applied to an event bus device, and the event processing device includes an information obtaining module and an information processing module;
the information acquisition module is used for receiving event instances;
the information processing module is used for determining an event type of the event instance, the event type comprises at least one of intra-domain events and cross-domain events, and when the event instance belongs to the intra-domain events, the event instance is processed according to a first processing strategy, and the first processing strategy comprises intra-domain processing of the event instance based on the event bus device; and under the condition that the event instance belongs to a cross-domain event, processing according to a second processing strategy, wherein the second processing strategy comprises broadcasting the event instance so that a corresponding target event bus device carries out cross-domain processing on the event instance.
9. The event processing device of claim 8, wherein the event bus device comprises an event listener, a routing manager, an intra-domain processor, and a cross-domain processor;
the information obtaining module is used for receiving an event instance based on the event monitor and sending the event instance to the routing manager;
The information processing module is used for receiving an event instance based on the routing manager, determining the event type of the event instance, generating an event instance processing instruction and sending the event instance processing instruction to the intra-domain processor under the condition that the event instance belongs to an intra-domain event, and routing the event instance to the corresponding intra-domain event processor for processing based on the intra-domain processor; and under the condition that the event instance belongs to a cross-domain event, generating an event instance processing instruction, sending the event instance processing instruction to the cross-domain processor, generating an event instance transmission instruction according to the event instance processing instruction based on the cross-domain processor, and broadcasting the event instance transmission instruction to a multicast network so as to enable a target cross-domain processor corresponding to the event instance transmission instruction to process the event instance.
10. An electronic device, comprising: a memory, a processor and a computer program stored on the memory and executable on the processor, the processor implementing the event processing method of any of claims 1 to 7 when the program is executed.
11. A computer readable storage medium, characterized in that the computer readable storage medium comprises a computer program, which when run controls an electronic device in which the computer readable storage medium is located to perform the event processing method according to any of claims 1 to 7.
CN202310777722.7A 2023-06-28 2023-06-28 Event processing method, device, equipment and medium Pending CN116795496A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310777722.7A CN116795496A (en) 2023-06-28 2023-06-28 Event processing method, device, equipment and medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310777722.7A CN116795496A (en) 2023-06-28 2023-06-28 Event processing method, device, equipment and medium

Publications (1)

Publication Number Publication Date
CN116795496A true CN116795496A (en) 2023-09-22

Family

ID=88041798

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310777722.7A Pending CN116795496A (en) 2023-06-28 2023-06-28 Event processing method, device, equipment and medium

Country Status (1)

Country Link
CN (1) CN116795496A (en)

Similar Documents

Publication Publication Date Title
CN110278284B (en) Service calling method and device
US8849754B2 (en) Managing topical overlap during publication and subscription
CN109150572B (en) Method, device and computer readable storage medium for realizing alarm association
CN111163173B (en) Cluster configuration method and device, server and readable storage medium
CN109347901B (en) Method, medium, device and system for realizing consensus mechanism of block chain system
CN110247977B (en) Data fusion method and system based on edge calculation
CN110557416B (en) Multi-node collaborative blocking method and system
CN107423942B (en) Service transfer method and device
CN116566984B (en) Routing information creation method and device of k8s container cluster and electronic equipment
CN114817190A (en) Log synchronization method, device, system, equipment and storage medium
CN116489214A (en) Unified service scheduling method, device, medium and equipment based on micro service gateway
US11169863B2 (en) Dynamic management method for menu, server and system
CN110336752B (en) Method and system for improving local broadcast push efficiency
CN116795496A (en) Event processing method, device, equipment and medium
CN111475905B (en) Method and device for establishing road vehicle function safety development flow
CN113055461B (en) ZooKeeper-based unmanned cluster distributed cooperative command control method
CN110298630A (en) A kind of workflow engine
CN114268628B (en) Method, system, equipment and storage medium for networking cross-block chain service platform
US20230053967A1 (en) Group updating method, message sending method, and apparatuses
CN114710350A (en) Allocation method and device for callable resources
CN115550439B (en) Event management system and method
CN112995095A (en) Data processing method, device and computer readable storage medium
CN113806056B (en) Timed task processing method, device, computer equipment and storage medium
CN115865651B (en) Data acquisition method and device, electronic equipment and storage medium
CN114531366B (en) Service treatment method and device

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