(public Alpha)

RECQ Patterns

-

Reactive Event Driven Commands and Queries

Three patterns to design Reactive Systems

Introduction

RECQ?

RECQ (Reactive, Event-Driven Commands and Queries) is a set of principles and architectural, methodological, behavioral, structural patterns aimed at the creation of softwares with Event-driven Microservices architectures compliant to the Reactive Manifesto and the more recent Reactive Principles.

Underlying Concepts

Distributed Systems & Microservices

Distributed systems are networks of interconnected computers that work together to achieve a common goal. They distribute tasks and data across multiple machines for improved performance, fault tolerance, and scalability. Distributed systems require careful coordination and communication to ensure consistency and synchronization of data. They provide a robust framework for efficient resource utilization and support the demands of modern computing environments.

Microservices   architecture is an approach to building applications as a collection of small, loosely coupled, and independently deployable services. Each service in a microservices architecture focuses on a specific business capability, and they communicate with each other through well-defined APIs.

https://microservices.io/patterns/microservices.html
https://www.reactivemanifesto.org/

Recative Manifesto & Reactive Principles

The Reactive Manifesto  outlines principles for building responsive, resilient, elastic, and message-driven systems. It emphasizes timely feedback, fault tolerance, dynamic scalability, and efficient communication. By following these principles, developers can create applications capable of handling high concurrency, adapting to changing conditions, and delivering reliable user experiences.

The Reactive Principles is a document that provides guidance and techniques established among experienced Reactive practitioners for building individual services, applications, and whole systems. As a companion to the Reactive Manifesto it incorporates the ideas, paradigms, methods, and patterns from both Reactive Programming and Reactive Systems into a set of practical principles that software architects and developers can apply in their transformative work.

State-of-the-art

DDD (Domain Driven Design)    is a design approach based on the domain model to analize, design and implement systems for scalability and maintainability.

CQRS (Command Query Responsability Separation)    is a design pattern that separates the read and write operations of an application, optimizing performance, scalability, and flexibility.

Event Sourcing    is a pattern where the state of an application is derived by replaying events. Events are stored as a log, enabling auditability, temporal queries, and reconstructing state at any point in time.

Messaging   pattern involves communication between microservices through asynchronous message passing using message queues or event-driven systems, promoting loose coupling, scalability, and fault tolerance in distributed systems.

Saga   is a design pattern for handling long-lived transactions in distributed systems. It ensures eventual consistency by coordinating a sequence of local transactional steps across multiple services.

RECQ Patterns

RECQ System Pattern

This is an architectural pattern that defines modules at a high level that make up a RECQ system. A RECQ System consists of the following modules:
  • Components    – Self-contained portions of software that implement application logic.
  • Message Gateway    – Component that manages communication between components in terms of requests and responses.
  • System State Store    – Component responsible for persisting system state in the form of event logs.
“RECQ system is a set of computational units called components that communicate with each other by exchanging messages; if a component causes the system state to change, this information is published as an event in the System State Store, furthermore, the components can listen for system state changes to change their internal state without an explicit message from another component.”

RECQ Communication Pattern

This is a behavioural pattern that defines how modules and elements communicate with each other. There are only three types of allowed communication:

RECQ Component Pattern

This is a methodological pattern that defines seven types of components. For each component, the applicable semantics and set of capabilities have been defined.

  • Aggregate   – is a component that implements the Command Model of the CQRS pattern. It is defined as such because it is the implementation of a Domain Driven Design Aggregate.
  • Projector    – is a component that implements the Query Model of the CQRS pattern, but only deals with the writing part of the local model.
  • Projection    – implements the Query Model read part of the CQRS pattern.
  • Service    – is a component that also implements the Command Model of the CQRS pattern. Unlike the aggregate, it is not responsible for a state or its state is external to the system (not the responsibility of the system).
  • Invoker    –  is a component that can only “invoke” others, it is a bridge between the outside of the system and the inside.
  • Saga    – implements the Saga Pattern for handling distributed transactions using an internal persistent state.
  • Observer    – While a Saga must have an internal state in order to understand how to move a transaction forward, an Observer (Observer) has no historical memory and reacts to a single event.

To deep dive inside this consepts, check our documentation where you can find a complete definition of the RECQ patterns.