Java – What’s the difference between reactive programming and event driven architecture

Architecturedesignevent-programmingjavareactive

What's the difference between reactive programming and event driven architecture?

Is reactive programming a way of implementing event driven programming?

Best Answer

Reactive Programming

A number of people have identified an increasing importance of a certain combination of desired properties for a certain kind of modern large-scale software systems. In concert, these properties satisfy typical non-functional requirements related to scalability, flexibility, robustness, ressource consumptions etc. This emerging notion has been coined reactiveness and the set of properties that constitute reactive systems has been defined in the reactive manifesto. The main characteristics are: responsiveness, resiliency, elasticity, and being message-driven. Currently, this is probably the most widely agreed-upon definition of reactive systems. Based on this general notion of reactive systems, reactive programming can be assumed to refer to any paradigm, pattern or technique that facilitates the realization of these properties in software.

Having said that, on a more technical level, reactive programming currently is understood as a programming model that has traditionally been known as dataflow programming that is having a renaissance because it is leveraged in an increasing amount of programming languages, frameworks and libraries to provide the aforementioned properties.

The systems from which the properties that constitute reactive systems have been derived typically make use of a variant of dataflow programming in which explicit handling of messages between components facilitates fault-tolerancy, the handling of back pressure and enable efficient use of ressources in highly dynamic settings by non-blocking communication.

Event-Driven Architecture

Event-driven architecture is a rather vaguely defined umbrella term for architecural patterns that certain people have identified as of increasing usefulness for certain applications. In this case, the notion largely stems from patterns that have emerged in the community of enterprise software in which microservices have emerged as a decomposition and deployment pattern to provide certain organizational benefits, i.e. to help distribute work within large projects.

While many classic concepts in software development such as object-oriented programming can be considered event-driven - communication between actors can be considered as events - it is especially this incarnation of designing an application by considering events as basic building blocks that is currently understood as event-driven. Often times people also associate with the term several patterns that extend this basic idea such as event-sourcing, and CQRS to provide several benefits that currently appear benefitial for certain applications.

Comparison

In comparison, at the heart of both notions lies asynchronous communication to decouple components. Events and messages are related notions, mostly differing in the intent that is emphasized by each term. As such they are a common ingredient of both notions. In a strict sense, being event-driven, today, is a prerequisite for being responsive. Personally, I can imagine that other paradigms may emerge to achieve the desired behavioral properties of reaponsive systems.

While the reactive manifesto emphasizes the above mentioned quality attributes related to how the system behaves at runtime and responds dynamically, event-driven architecture focuses on how a system is decomposed and how its parts generally interact. In this sense, the perspective of reactive systems is a rather behavioristical one, even though it assumes certain properties related to its internal behavior, my impression is that these internal properties may be accidental in nature, i.e. the desired behavioral properties could be achieved by different means.

Each notion currently takes a different perspective on a software system, comes with a different set of typical associations, emphasizes different aspects and focuses on achieving different goals. However they will likely keep being recoined and might diverge or converge as the notions evolve.

Related Topic