Code Monkey home page Code Monkey logo

spring-boot-kafka-monorepo's Introduction

Spring Boot Kafka Monorepo

About This Project

This project demonstrates the use of Apache Kafka message broker to create a connection between microservices.

Here is the architecture of this project :

In this example project we will create a service that collects news data from a news collection API.

This project is consisted of :

  • Two Spring Boot microservices
    • user-api (act as REST API service)
    • worker (act as worker that collects data from news API)
  • Zookeeper (to run Apache kafka)
  • Apache Kafka message broker
  • Redis (to save cached date)
  • New API (we use Mediastack for this project)
  • Docker (to run Zookeeper, Apache Kafka, and Redis)

Project Setup

You have to do several steps to run or use this project in your machine.

First, you must install Zookeeper, Kafka, and Redis as these things are necessary to run this project.

You can simply install all of these things by executing this command :

docker-compose up -d

To check if the installation is successful, you can check that with this command :

docker ps

If you can see Zookeeper, Kafka, and Redis containers are running, they are successfully installed (like the example below)

CONTAINER ID   IMAGE                              COMMAND                  CREATED         STATUS        PORTS                                         NAMES
e5e5245248ed   confluentinc/cp-kafka:latest       "/etc/confluent/dock…"   47 hours ago    Up 11 hours   9092/tcp, 0.0.0.0:29092->29092/tcp            monorepo-kafka-1
bf3a4892effa   confluentinc/cp-zookeeper:latest   "/etc/confluent/dock…"   47 hours ago    Up 11 hours   2888/tcp, 3888/tcp, 0.0.0.0:22181->2181/tcp   monorepo-zookeeper-1
3b0f8606ad00   redis:latest                       "docker-entrypoint.s…"   47 hours ago    Up 12 hours   0.0.0.0:6379->6379/tcp                        monorepo-redis-1

You can do things like changing Redis password, giving a password for Kafka, changing topics name, etc. by editing docker-compose.yml file.

Second, check this two files :

make sure the Redis password or any custom setup related with Kafka are similar with the setup inside docker-compose.yml file.

Third, register an account to Mediastack and get your API key. Put the key inside application.yml (worker project)

mediastack:
  uri: http://api.mediastack.com/v1/news
  api-key: <your-api-key>
  countries: us
  limit: 25

How To Run The Project

First, make sure Redis, Zookeeper, and Apache Kafka are running.

Second, align all setups in both application.yml files with the setup in docker-compose.yml file.

Third, run all projects (user-api and worker) you can use ./gradlew bootRun command on each projects or simply use IDE (IntellIJ or Eclipse).

List Of API

We only have one API inside this project :

  • (GET) http://localhost:8080/message?date=<date>, date = yyyy-MM-dd

spring-boot-kafka-monorepo's People

Contributors

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