Code Monkey home page Code Monkey logo

sample-cqrs's Introduction

CQRS Sample

This sample code helps get you started with a CQRS + Event Sourcing Patterns

To know about CQRS: https://martinfowler.com/bliki/CQRS.html

To know about Event Sourcing: https://martinfowler.com/eaaDev/EventSourcing.html

Related technologies:

What's Here

This sample includes:

  • branch master - Normal spring boot application with servlet container.

  • branch webflux (In progress) - Spring Boot Webflux with Netty server, more functional style (See https://docs.spring.io/spring/docs/current/spring-framework-reference/web-reactive.html for details).

  • branch distributed-command - This branch uses Netflix Eureka to distribute commands.

  • README.md - this file

  • docker-compose.yml - this file is used by Docker Compose (https://docs.docker.com/compose/) to running Kafka, Zookeeper and Mongo

  • pom.xml - this file is the Maven Project Object Model for the web service

  • command-server - this directory contains your Kotlin Service Command source files

  • query-server - this directory contains your Kotlin Service Query source files

  • sample-core - this directory contains the shared source code between modules, command-server and query-server

  • service-discovery (branch distributed-command) - this directory contains your Service Discovery (Eureka) to enable distributed commands

Getting Started

To work on the sample code, you'll need to clone project's repository to your local computer. If you haven't, do that first.

  1. Install maven. See https://maven.apache.org/install.html for details.

  2. Install Docker (to run Kafka, Zookeeper and Mongo). See https://docs.docker.com/install/

  3. Build the services.

     $ cd sample-cqrs
     $ mvn clean install
    
  4. Run the Docker Compose.

     $ docker-compose up -d
    
  5. Run the Eureka (if distributed-command branch)

     $ cd service-discovery 
     $ mvn spring-boot:run 
    
  6. Run the Command Server

     $ cd command-server
     $ mvn spring-boot:run 
    
  7. Run the Query Server

     $ cd query-server
     $ mvn spring-boot:run 
    
  8. Send Command to create the sample data

    action types:

      CREATE
             
      CREATE_AND_CANCEL 
    

    The action (CREATE_AND_CANCEL) rollback status to CANCELED using Saga Pattern

     $ curl -v -X PUT \
         http://localhost:8084/command-sample/api/samples \
         -H 'Content-Type: application/json' \
         -d '{
         "id": 1234,
         "stuff": "Lorem Ipsum",
         "action": "CREATE"
       }'
    
  9. Call the Query endpoint

     $ curl -v -X GET http://localhost:8085/query-sample/api/samples/1234  
    

sample-cqrs's People

Contributors

hsenasilva avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.