Giter Club home page Giter Club logo

kafka_demo's Introduction

Description

This project demonstrates how to use a topic with two partitions and still have a consistent way of routing events.

We do have 2 apps:

  • order-app: exposes 2 REST endpoints, one to place a new order, and another to cancel it. When a place order is received, it saves it to a PostgreSQL database, sends a Kafka record to the "orders" topic (which has two partitions), and sends a response back to the UI.
  • billing-app: consumes from Kafka topic "orders" and prints them to the console. If only one billing-app is started, it will consume from both partitions of the "orders" topic, and will write in the console log each record consumed, if 2 instances of billing-app are run, each instance will consume only from one of the partitions. If one of the instances dies, the other will take over and continue listening from the partition that was assigned to the dead billing-app. If later on, a new instance of billing-app is started, partitions will be splitted amongst the two billing-app instances.

How to run it

Run the following command within the folder [PROJECT_ROOT_FOLDER]/docker: docker compose up -d

It will start a PostgreSQL database docker container (db), a database admin docker container (admin) and a few Kafka related docker containers:

  • schema-registry-1: keeps track of the different versions of the messages sent to the "orders" topic (in this project there's only one, but typically they evolve over time)
  • kafka-1 broker
  • zookeeper-1

Then start the OrderManagementApplication and the BillingApplication (you can start one or two instances of the billing-app)

The frontend UI can be started by changing to folder [PROJECT_ROOT_FOLDER]/ui and executing npm run dev, then open a web browser and navigate to http://localhost:5173/

Alternatively, execute the cucumber tests in file order-app/src/test/resources/bdd/order_management.feature

kafka_demo's People

Contributors

guillemplasencia avatar

Watchers

 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.