Event-driven architecture (EDA) is a
software architecture
Software architecture is the fundamental structure of a software system and the discipline of creating such structures and systems. Each structure comprises software elements, relations among them, and properties of both elements and relations.
...
paradigm promoting the production, detection, consumption of, and reaction to
event
Event may refer to:
Gatherings of people
* Ceremony, an event of ritual significance, performed on a special occasion
* Convention (meeting), a gathering of individuals engaged in some common interest
* Event management, the organization of e ...
s.
Overview
An ''event'' can be defined as "a significant change in
state
State may refer to:
Arts, entertainment, and media Literature
* ''State Magazine'', a monthly magazine published by the U.S. Department of State
* ''The State'' (newspaper), a daily newspaper in Columbia, South Carolina, United States
* ''Our S ...
". For example, when a consumer purchases a car, the car's state changes from "for sale" to "sold". A car dealer's system architecture may treat this state change as an event whose occurrence can be made known to other applications within the architecture. From a formal perspective, what is produced, published, propagated, detected or consumed is a (typically asynchronous) message called the event notification, and not the event itself, which is the state change that triggered the message emission. Events do not travel, they just occur. However, the term ''event'' is often used
metonymically
Metonymy () is a figure of speech in which a concept is referred to by the name of something closely associated with that thing or concept.
Etymology
The words ''metonymy'' and ''metonym'' come from grc, μετωνυμία, 'a change of name ...
to denote the notification message itself, which may lead to some confusion. This is due to Event-driven architectures often being designed atop message-driven architectures, where such communication pattern requires one of the inputs to be text-only, the message, to differentiate how each communication should be handled.
This
architectural pattern may be applied by the design and implementation of applications and systems that transmit events among
loosely coupled software components and
services
Service may refer to:
Activities
* Administrative service, a required part of the workload of university faculty
* Civil service, the body of employees of a government
* Community service, volunteer service for the benefit of a community or a p ...
. An event-driven system typically consists of event emitters (or agents), event consumers (or sinks), and event channels. Emitters have the responsibility to detect, gather, and transfer events. An Event Emitter does not know the consumers of the event, it does not even know if a consumer exists, and in case it exists, it does not know how the event is used or further processed. Sinks have the responsibility of applying a reaction as soon as an event is presented. The reaction might or might not be completely provided by the sink itself. For instance, the sink might just have the responsibility to filter, transform and forward the event to another component or it might provide a self-contained reaction to such event. Event channels are conduits in which events are transmitted from event emitters to event consumers. The knowledge of the correct distribution of events is exclusively present within the event channel. The physical implementation of event channels can be based on traditional components such as
message-oriented middleware
Message-oriented middleware (MOM) is software or hardware infrastructure supporting sending and receiving messages between distributed systems. MOM allows application modules to be distributed over heterogeneous platforms and reduces the comple ...
or point-to-point communication which might require a more appropriate .
Building systems around an event-driven architecture simplifies horizontal scalability in
distributed computing
A distributed system is a system whose components are located on different networked computers, which communicate and coordinate their actions by passing messages to one another from any system. Distributed computing is a field of computer sci ...
models and makes them more resilient to failure. This is because application state can be copied across multiple parallel snapshots for high-availability.
[Martin Fowler]
Event Sourcing
December, 2005 New events can be initiated anywhere, but more importantly propagate across the network of data stores updating each as they arrive. Adding extra nodes becomes trivial as well: you can simply take a copy of the application state, feed it a stream of events and run with it.
[Martin Fowler]
December, 2005
Event-driven architecture can complement
service-oriented architecture
In software engineering, service-oriented architecture (SOA) is an architectural style that focuses on discrete services instead of a monolithic design. By consequence, it is also applied in the field of software design where services are provide ...
(SOA) because services can be activated by triggers fired on incoming events.
This paradigm is particularly useful whenever the sink does not provide any .
SOA 2.0 evolves the implications SOA and EDA architectures provide to a richer, more robust level by leveraging previously unknown causal relationships to form a new event pattern. This new
business intelligence
Business intelligence (BI) comprises the strategies and technologies used by enterprises for the data analysis and management of business information. Common functions of business intelligence technologies include reporting, online analytical p ...
pattern triggers further autonomous human or automated processing that adds exponential value to the enterprise by injecting value-added information into the recognized pattern which could not have been achieved previously.
Event structure
An event can be made of two parts, the event header and the event body. The event header might include information such as event name, time stamp for the event, and type of event.
The event body provides the details of the state change detected. An event body should not be confused with the pattern or the logic that may be applied in reaction to the occurrence of the event itself.
Event flow layers
An event driven architecture may be built on four logical layers, starting with the sensing of an event (i.e., a significant temporal state or fact), proceeding to the creation of its technical representation in the form of an event structure and ending with a non-empty set of reactions to that event.
Event Producer
The first logical layer is the event producer, which senses a fact and represents that fact as an event message. As an example, an event producer could be an email client, an E-commerce system, a monitoring agent or some type of physical sensor.
Converting the data collected from such a diverse set of data sources to a single standardized form of data for evaluation is a significant task in the design and implementation of this first logical layer.
However, considering that an event is a strongly declarative frame, any informational operations can be easily applied, thus eliminating the need for a high level of standardization.
Event channel
This is the second logical layer. An event channel is a mechanism of propagating the information collected from an event generator to the event engine
or sink.
This could be a TCP/IP connection, or any type of an input file (flat, XML format, e-mail, etc.). Several event channels can be opened at the same time. Usually, because the event processing engine has to process them in near real time, the event channels will be read asynchronously. The events are stored in a queue, waiting to be processed later by the event processing engine.
Event processing engine
The event processing engine is the logical layer responsible for identifying an event, and then selecting and executing the appropriate reaction. It can also trigger a number of assertions. For example, if the event that comes into the event processing engine is a product ID low in stock, this may trigger reactions such as “Order product ID” and “Notify personnel”.
Downstream event-driven activity
This is the logical layer where the consequences of the event are shown. This can be done in many different ways and forms; e.g., an email is sent to someone and an application may display some kind of warning on the screen.
Depending on the level of automation provided by the sink (event processing engine) the downstream activity might not be required.
Event processing styles
There are three general styles of event processing: simple, stream, and complex. The three styles are often used together in a mature event-driven architecture.
[Brenda M. Michelson, Event-Driven Architecture Overview, ''Patricia Seybold Group'', February 2, 2006]
Simple event processing
Simple event processing concerns events that are directly related to specific, measurable changes of condition. In simple event processing, a notable event happens which initiates downstream action(s). Simple event processing is commonly used to drive the real-time flow of work, thereby reducing lag time and cost.
For example, simple events can be created by a sensor detecting changes in tire pressures or ambient temperature. The car's tire incorrect pressure will generate a simple event from the sensor that will trigger a yellow light advising the driver about the state of a tire.
Event stream processing
In
event stream processing
In computer science, stream processing (also known as event stream processing, data stream processing, or distributed stream processing) is a programming paradigm which views data streams, or sequences of events in time, as the central input and o ...
(ESP), both ordinary and notable events happen. Ordinary events (orders, RFID transmissions) are screened for notability and streamed to information subscribers. Event stream processing is commonly used to drive the real-time flow of information in and around the enterprise, which enables in-time decision making.
Complex event processing
Complex event processing Event processing is a method of tracking and analyzing (processing) streams of information (data) about things that happen (events), and deriving a conclusion from them. Complex event processing, or CEP, consists of a set of concepts and techniques ...
(CEP) allows patterns of simple and ordinary events to be considered to infer that a complex event has occurred. Complex event processing evaluates a confluence of events and then takes action. The events (notable or ordinary) may cross event types and occur over a long period of time. The event correlation may be causal, temporal, or spatial. CEP requires the employment of sophisticated event interpreters, event pattern definition and matching, and correlation techniques. CEP is commonly used to detect and respond to business anomalies, threats, and opportunities.
Online event processing
Online event processing (OLEP) uses asynchronous distributed event-logs to process complex events and manage persistent data. OLEP allows to reliably compose related events of a complex scenario across heterogeneous systems. It therewith enables very flexible distribution patterns with high scalability and offers strong consistency. However, it cannot guarantee an upper bound to the processing time.
Extreme loose coupling and well distributed
An event driven architecture is extremely loosely coupled and well distributed. The great distribution of this architecture exists because an event can be almost anything and exist almost anywhere. The architecture is extremely loosely coupled because the event itself doesn't know about the consequences of its cause. e.g. If we have an alarm system that records information when the front door opens, the door itself doesn't know that the alarm system will add information when the door opens, just that the door has been opened.
Semantic Coupling and further research
Event driven architectures have loose coupling within space, time and synchronization, providing a scalable infrastructure for information exchange and distributed workflows. However, event-architectures are tightly coupled, via event subscriptions and patterns, to the semantics of the underlying event schema and values. The high degree of semantic heterogeneity of events in large and open deployments such as smart cities and the sensor web makes it difficult to develop and maintain event-based systems. In order to address semantic coupling within event-based systems the use of approximate
semantic matching Semantic matching is a technique used in computer science to identify information which is semantically related.
Given any two graph-like structures, e.g. classifications, taxonomies database or XML schemas and ontologies, matching is an operato ...
of events is an active area of research.
[Hasan, Souleiman, Sean O’Riain, and Edward Curry. 2012]
“Approximate Semantic Matching of Heterogeneous Events.”
In 6th ACM International Conference on Distributed Event-Based Systems (DEBS 2012), 252–263. Berlin, Germany: ACM
“DOI”
Implementations and examples
Java Swing
The
Java
Java (; id, Jawa, ; jv, ꦗꦮ; su, ) is one of the Greater Sunda Islands in Indonesia. It is bordered by the Indian Ocean to the south and the Java Sea to the north. With a population of 151.6 million people, Java is the world's mos ...
Swing API is based on an event driven architecture. This works particularly well with the motivation behind Swing to provide user interface related components and functionality. The API uses a nomenclature convention (e.g. "ActionListener" and "ActionEvent") to relate and organize event concerns. A class which needs to be aware of a particular event simply implements the appropriate listener, overrides the inherited methods, and is then added to the object that fires the event. A very simple example could be:
public class FooPanel extends JPanel implements ActionListener
Alternatively, another implementation choice is to add the listener to the object as an
anonymous class
In object-oriented programming, a class is an extensible program-code-template for creating objects, providing initial values for state (member variables) and implementations of behavior (member functions or methods). In many languages, the class n ...
and thus use the lambda notation (since Java 1.8). Below is an example.
public class FooPanel extends JPanel
JavaScript
(() => )();
Usage:
const events = new EventEmitter();
events.on('foo', () => );
events.emit('foo'); // Prints "foo"
events.off('foo');
events.emit('foo'); // Nothing will happen
Object Pascal
Events are one of the fundamental elements of the
Object Pascal
Object Pascal is an extension to the programming language Pascal that provides object-oriented programming (OOP) features such as classes and methods.
The language was originally developed by Apple Computer as ''Clascal'' for the Lisa Worksh ...
language. The uni-cast model (one-to-one) is used here, i.e. the sender sends information to only one recipient. This limitation has the advantage that it does not need a special event listener. The event itself is a pointer to a method in another object. If the pointer is not empty, when an event occurs, the event handler is called. Events are commonly used in classes that support GUI. This is not the only area of application for events, however. The following code is an example of using events:
unit MyCustomClass;
interface
uses
Classes;
type
TAccidentEvent = procedure(Sender: TObject; const AValue: Integer) of object;
TMyCustomObject = class(TObject)
private
FData: Integer; // an example of a simple field in a class
FOnAccident: TAccidentEvent; // event - reference to a method in some object
FOnChange: TNotifyEvent; // event - reference to a method in some object
procedure SetData(Value: Integer); // a method that sets the value of a field in the class
protected
procedure DoAccident(const AValue: Integer); virtual; // a method that generates an event based on your own definition
procedure DoChange; // a method that generates an event based on a definition from the VCL library
public
constructor Create; virtual; // class constructor
destructor Destroy; override; // class destructor
published
property Data: TAccidentEvent read FData write SetData; // declaration of a property in a class
property OnAccident: TAccidentEvent read FOnAccident write FOnAccident; // exposing the event outside the class
property OnChange: TNotifyEvent read FOnChange write FOnChange; // exposing the event outside the class
procedure MultiplyBy(const AValue: Integer); // a method that uses its own definition of the event
end;
implementation
constructor TMyCustomObject.Create;
begin
FData := 0;
end;
destructor TMyCustomObject.Destroy;
begin
FData := 0;
inherited Destroy;
end;
procedure TMyCustomObject.DoAccident(const AValue: Integer);
begin
if Assigned(FOnAccident)
then FOnAccident(Self, AValue);
end;
procedure TMyCustomObject.DoChange;
begin
if Assigned(FOnChange)
then FOnChange(Self);
end;
procedure TMyCustomObject.MultiplyBy(const AValue: Integer);
begin
FData := FData * AValue;
if FData > 1000000
then DoAccident(FData);
end;
procedure TMyCustomObject.SetData(Value: Integer);
begin
if FData <> Value
then
begin
FData := Value;
DoChange;
end;
end.
The created class can be used as follows:
...
procedure TMyForm.ShowCustomInfo(Sender: TObject);
begin
if Sender is TMyCustomObject
then ShowMessage('Data has changed.');
end;
procedure TMyForm.PerformAcident(Sender: TObject; const AValue: Integer);
begin
if Sender is TMyCustomObject
then ShowMessage('The data has exceeded 1000000! New value is: ' + AValue.ToString);
end;
...
var
LMyObject: TMyCustomObject;
...
LMyObject := TMyCustomObject.Create;
...
LMyObject.OnChange := MyForm.ShowCustomInfo;
LMyObject.OnAccident := MyForm.PerformAcident;
...
LMyObject.Free;
...
See also
*
Event-driven programming
In computer programming, event-driven programming is a programming paradigm in which the flow of the program is determined by events such as user actions (mouse clicks, key presses), sensor outputs, or message passing from other programs or thr ...
*
Process Driven Messaging Service A process driven messaging service (PDMS) is a service that is process oriented and exchanges messages/data calls. A PDMS is a service where jobs and triggers can be put together to create a workflow for a message.
Messaging platforms are conside ...
*
Service-oriented architecture
In software engineering, service-oriented architecture (SOA) is an architectural style that focuses on discrete services instead of a monolithic design. By consequence, it is also applied in the field of software design where services are provide ...
*
Event-driven SOA Event-driven SOA is a form of service-oriented architecture (SOA), combining the intelligence and proactiveness of event-driven architecture with the organizational capabilities found in service offerings. Before event-driven SOA, the typical SOA ...
*
Space-based architecture
A Space-based architecture (SBA) is an approach to distributed computing systems where the various components interact with each other by ''exchanging'' tuples or entries via one or more shared spaces. This is contrasted with the more common Mess ...
*
Complex event processing Event processing is a method of tracking and analyzing (processing) streams of information (data) about things that happen (events), and deriving a conclusion from them. Complex event processing, or CEP, consists of a set of concepts and techniques ...
*
Event stream processing
In computer science, stream processing (also known as event stream processing, data stream processing, or distributed stream processing) is a programming paradigm which views data streams, or sequences of events in time, as the central input and o ...
*
Event Processing Technical Society
Event Processing Technical Society (EPTS) is an inclusive group of organizations and individuals aiming to increase awareness of event processing, foster topics for future standardization, and establish event processing as a separate academic disc ...
*
Staged event-driven architecture The staged event-driven architecture (SEDA) refers to an approach to software architecture that decomposes a complex, event-driven application into a set of stages connected by queues. It avoids the high overhead associated with thread-based concu ...
(SEDA)
*
Reactor pattern
The reactor design pattern is an event handling pattern for handling service requests delivered concurrently to a service handler by one or more inputs. The service handler then demultiplexes the incoming requests and dispatches them synchronou ...
*
Autonomous peripheral operation
In computing, autonomous peripheral operation is a hardware feature found in some microcontroller architectures to off-load certain tasks into embedded autonomous peripherals in order to minimize latencies and improve throughput in hard real-tim ...
Articles
*Article defining the differences between EDA and SOA:
How EDA extends SOA and why it is important' by Jack van Hoof.
*Real-world example of business events flowing in an SOA:
SOA, EDA, and CEP - a winning combo' by Udi Dahan.
*Article describing the concept of event data:
Analytics for hackers, how to think about event data' by Michelle Wetzler. (Web archive)
References
{{Reflist
External links
Event-Driven Applications: Costs, Benefits and Design Approaches5th Anniversary Edition: Event-Driven Architecture Overview, Brenda M. Michelson
Enterprise application integration
Software architecture
Service-oriented (business computing)
Events (computing)
Articles with example Java code