Evento Framework
  • Introduction
  • Architecture Overview
    • Distributed Systems & Microservices
    • Recative Manifesto & Reactive Principles
    • State-of-the-art Patterns
      • DDD (Domain Driven Design)
      • CQRS (Command Query Responsability Separation)
      • Event Sourcing
      • Messaging
      • Saga
  • GETTING STARTED
    • Quick Start
    • TodoList - RECQ Tutorial
      • Problem Description and Requirement Gathering
      • RECQ Payload Design
      • RECQ Components Design
      • Set up your Development Environment
      • RECQ Payload Evento Implementation
        • Domain Commands
        • Domain Events
        • Views
        • Queries
      • RECQ Components Evento Implementation with Spring Data
        • TodoListAggregate
        • TodoList Model with Spring Data
        • TodoListProjector
        • TodoListProjection
        • TodoList Invoker
      • Expose the RECQ architecture with Spring Web
      • Test Your App
    • Extend TodoList - Handle Complexity Tutorial
      • Unique identifier generation
      • Extends behaviors with Observer and Services
      • Cross Domain Consistency with Sagas
      • Handle Real time data updates with MQTT and Save-Notify Pattern
  • RECQ Patterns
    • RECQ Patterns
    • RECQ System Pattern
      • Component
      • Message Gateway
      • System State Store
    • RECQ Communication Pattern
      • Component to Component
      • Component to System State Store
      • System State Store to Component
    • RECQ Component Pattern
      • Aggregate
      • Projector
      • Projection
      • Service
      • Invoker
      • Saga
      • Observer
  • Evento Framework
    • Evento Framework Introcution
    • Payload and Messages
      • Command
        • Domain Command
        • Service Command
      • Event
        • Domain and Service Event
      • Query and View
    • @Component
      • @Aggregate
        • Aggregate State
        • @AggregateCommandHandler
        • @EventSourcingHandler
      • @Projector
        • Projector @EventHandler
      • @Projection
        • @QueryHandler
      • @Service
        • @CommandHandler
      • @Invoker
      • @Saga
        • SagaState
        • @SagaEventHandler
      • @Observer
    • Dead Event Queues
    • EventoBundle
      • EventoServerMessageBusConfiguration
      • ConsumerStateStore
        • InMemoryConsumerStateStore
        • PostgresConsumerStateStore
        • MysqlConsumerStateStore
      • Context
      • TracingAgend and @Track
        • SentryTracingAgent
      • Autoscaling Protocol
        • ThreadCountAutoscalingProtocol
      • Injector and @Component
  • Evento Server
    • Evento Server Introduction
    • SetUp Evento Server
      • Advanced Options
      • Evento Event Store Modes: APES and CPES
    • Evento Server Cluster
    • Bundle Deploy Script
  • EVENTO GUI
    • Explore RECQ Systems Visually
    • GUI Auth
    • Payload Catalog
    • Component Catalog
    • Bundle Catalog
    • Cluster Status (Experimental)
    • Flows
      • Performance Evaluation
    • Application Graph
    • System State Store
  • Evento CLI
    • Evento CLI Introduction
    • Update Version
    • Publish
Powered by GitBook
On this page
  1. RECQ Patterns
  2. RECQ Component Pattern

Observer

Component like Saga but does not hold a state and has no order constraints.

PreviousSagaNextEvento Framework Introcution

Last updated 1 year ago

Observers are specialized components designed to react to and potentially trigger actions based on a single event. Unlike Sagas that manage complex workflows, Observers are lightweight and stateless, making them ideal for simple event-driven reactions.

The EventHandler Method: A Single Event, Focused Action

Similar to Projectors and Sagas, Observers expose an EventHandler method. This method takes centre stage when a relevant Event arrives:

  • Event as Input: The EventHandler receives the relevant Event as input.

  • Action Execution: Based on the received Event, the Observer can:

    • Send Command-type messages to trigger actions within Aggregates or Services.

    • Send Query-type messages to retrieve information from other components.

Stateless Design for Unmatched Scalability

Unlike Sagas, Observers embrace a completely stateless design. They do not maintain any historical data about past events. This stateless nature allows for exceptional scalability – you can effortlessly add more Observer instances to handle increasing event loads without compromising consistency.

Event Consumption: Flexibility over Order

Observers differ from Projectors and Sagas in their approach to event consumption. Projectors and Sagas typically require sequential processing to ensure consistency within read models or workflows. In contrast, Observers do not have strict ordering requirements for event consumption. They simply react to individual events as they arrive.

Special Case of Sagas: A Simpler Approach

As the definition highlights, Observers can be considered a special case of Sagas. They operate in a similar fashion, triggering actions based on events, but they lack the internal state and multi-step workflow management capabilities of Sagas. This makes Observers more lightweight and suitable for simpler event-driven reactions.

Comparison with Services: Reacting vs. Acting

While Observers share some similarities with Services in their ability to send Command and Query messages, there's a key distinction. Services often represent functionalities directly exposed to external actors, initiating actions within the system. On the other hand, Observers primarily react to events that have already occurred within the system, triggering secondary actions in response.

Observers in Action: Streamlined Event-Driven Responses

Observers are valuable for scenarios where you need a component to react to specific events and trigger lightweight actions. They are well-suited for tasks like sending notifications, updating caches, or performing simple data transformations triggered by incoming events. Their stateless nature and flexible event consumption make them highly scalable, allowing you to efficiently handle large volumes of events without impacting system performance.

Capability

Can handle Command Messages

No

Can handle Query Messages

No

Can handle Events

Yes

Can send Command Messages

No

Can Send Query Messages

Yes

State type

No

CAP Properties

AP

RECQ Observer Big Picture
Observer Structure