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 Communication Pattern

Component to Component

Asynchronous Messaging and CQRS

In a RECQ architecture, components communicate with each other indirectly through asynchronous message exchange facilitated by the Message Gateway. This communication adheres to the Command Query Responsibility Segregation (CQRS) pattern, enforcing a clear separation between commands that modify the system state and queries that retrieve data without causing state changes.

Message Types and Protocols:

  • Commands:

    • Commands typically follow a request/reply pattern:

      • The component sends a command message to the Message Gateway, specifying the desired action.

      • The Message Gateway routes the command to the appropriate Command Service.

      • The Command Service processes the command and performs the requested action.

      • The Command Service sends a response message back through the Message Gateway, indicating the success or failure of the operation.

      • The Message Gateway delivers the response message to the originating component.

    • Since the CQRS pattern is enforced, the response message for a command typically only includes confirmation of success or failure (e.g., boolean flag or error code) and not the updated data itself.

  • Queries:

    • Queries typically follow a request/reply pattern:

      • The component sends a query message to the Message Gateway, specifying the requested data.

      • The Message Gateway routes the query to the appropriate Query Service.

      • The Query Service retrieves the data from the system state or relevant data store.

      • The Query Service sends a response message back through the Message Gateway, containing the requested data (the Views).

      • The Message Gateway delivers the response message containing the data (Views) to the originating component.

Benefits of Asynchronous Messaging and CQRS:

  • Improved Scalability and Performance: Asynchronous message exchange allows components to send requests without waiting for immediate responses. This decouples components and enables independent scaling based on their workload.

  • Enhanced Maintainability: Separating commands and queries simplifies the logic within each component and promotes code clarity.

  • Optimized Event Sourcing: Separating commands from queries, updating the system state with commands and retrieving data through queries promotes a cleaner separation of concerns for event sourcing.

Considerations:

  • Increased Complexity: Asynchronous messaging and CQRS introduce additional complexity compared to simpler synchronous communication patterns.

  • Potential for Data Inconsistency: In rare cases, if events haven't been processed by the System State Store when a query is sent, the retrieved data might not reflect the latest state. Techniques like eventual consistency or materialized views can be used to mitigate this.

Conclusion:

Leveraging asynchronous messaging with the mandatory Message Gateway and adhering to the CQRS pattern provides a robust and scalable approach for component-to-component communication in a RECQ architecture. This approach promotes loose coupling, improves maintainability, and optimizes event sourcing for event-driven microservices.

PreviousRECQ Communication PatternNextComponent to System State Store

Last updated 1 year ago

Component to Component Communication