Event-Driven Architecture vs. Publish-Subscribe Systems
This article is the fourth in a series about the Event Web (EW), a thin layer on top of the World Wide Web that continuously monitors information sources and responds appropriately as conditions change. The EW, based on service-oriented architecture (SOA) and event-driven architecture (EDA), can also serve as a platform for Sense and Respond (S&R) systems, a new type of application that continuously responds to critical conditions.
This installment discusses EDA in relation to traditional publish-subscribe (pub-sub) systems.
As described in a previous article, software architectures consist of:
- Compositional operators (for plugging components together), and
The contract or specification associated with a component tells systems designers everything they need to know about the component. This article shows that EDA is much more powerful than the traditional pub-sub architecture because of the flexibility and dynamic nature of contracts between subscriber (client) and publisher (server). The goal is to explore the richness of EDA contracts and explain the design consequences of this richness.
As discussed in the previous article, EDA has two components:
- agents and
Agents come in three types:
- event-processing agents (EPAs), and
Sensors, such as temperature sensors, monitor the environment and generate messages (events) that describe some aspect of the environment's state, such as temperature. Event-processing agents receive multiple streams of messages, process them, and generate message streams in turn. Responders, such as the controller of an airplane rudder, receive message streams and modify the state of the environment (by moving the rudder, for instance).
In animals, sensors are eyes and other sensory organs, the nervous system is a network of EPAs, and muscles are responders.
Streams are sequences of messages. EDA has two types of streams, event streams and control streams. A message in an event stream contains information, such as temperature, about the system state. A message in a control stream contains commands to specify, or update, subscriptions that specify the types of event messages that should be sent to the subscriber.
In animals, the sequences of messages from the eyes to the central nervous system are event streams. These messages contain information that the eye sensed about the environment. A sequence of messages that the central nervous system sends to the eye, telling the eye what to watch out for, is a control stream. In a jungle, the eye may be commanded to look out for snake-like objects, while in the ocean the eye may be told to look for jelly fish-like objects.
Control streams between nodes of the network are crucial to the efficacy of an EDA application. Contracts between agents specify the relationship between the event and control streams that flow between them. The flexibility of the relationship between event and control streams makes EDA powerful. The following section explores these contracts in detail.