Git Product home page Git Product logo

cqrs-es-kafka's Introduction

Elastic Applications with Apache Kafka

Sample Implementation

The purpose of this repository is to provide a reference implementation for a sample application that demonstrates the usage of Apache Kafka. The detailed description for the application architecture and the styles underpinning it, please check my blog on Ghost.io

Architectural Styles

The implementation adapts the following architectural styles:

  1. Domain Driven Design
  2. Command Query Responsibility Segregation
  3. Event Sourcing

Technology

The application uses the following set of light-weight technologies and frameworks:

  1. Apache Kafka for Messaging
  2. MongoDB for Persistence
  3. Spring MVC for REST Services
  4. Spring Data for Data Access Objects
  5. Spring Boot for Bootstrapping and Boilerplates

Prerequisites

Before running the above application, you'll need to install the following on your machine:

  1. Maven 3.0.3 or later
  2. MongoDB, I used v3.2 at the time of this implementation
  3. Apache Kafka v0.9 or later

If you have a Mac OS, you can install the above components using Homebrew. The following commands install the above:

$ brew install maven
$ brew install kafka
$ brew install mongodb

Run

Once you have the above software installed, you can run the application in the following order:

  1. Go to the root directory of the application and type: mvn clean install
  2. Start the application-api project which is the entry point for REST URL's of the commands. You can start it by navigating to its subdirectory and type: mvn spring-boot:run
  3. Start the application project which contains the domain logic and event sourcing. You can start it by navigating to its subdirectory and type: mvn spring-boot:run
  4. Start the query-api project which represents the query part subscribing to the published events. You can start it by navigating to its subdirectory and type: mvn spring:boot:run

Variations

The above steps assume the default settings for Mongo and Kafka. If you could like to change any of those settings, please navigate to application.properties file that you'll find under each of the three applications above and then change the proper values and re-run it again.

Interaction

The command part can be tested by POSTing a JSON message to the following REST endpoint: http://localhost:8080/profiles/registrations and the sample JSON request is:

{
    "username": "username",
    "email": "[email protected]",
    "password": "password"
}

As for the query part, you can test it by GET the following REST endpoint: http://localhost:9090/profiles

You can also check the messages as it passes through Kafka using the ./topic-console-consumer utility

cqrs-es-kafka's People

Contributors

enctl avatar

Watchers

 avatar  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.