Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

The goal of this project is to implement two Spring Boot applications: bitcoin-api and bitcoin-client. The bitcoin-api application simulates BTC price changes, while the bitcoin-client application listens to these changes and updates a real-time UI. The bitcoin-client UI is secured using Basic Authentication.

NotificationsYou must be signed in to change notification settings

ivangfr/springboot-kafka-websocket

Repository files navigation

The goal of this project is to implement twoSpring Boot applications:bitcoin-api andbitcoin-client. Thebitcoin-api application simulatesBTC price changes, while thebitcoin-client application listens to these changes and updates a real-time UI. Thebitcoin-client UI is secured using Basic Authentication.

Proof-of-Concepts & Articles

Onivangfr.github.io, I have compiled my Proof-of-Concepts (PoCs) and articles. You can easily search for the technology you are interested in by using the filter. Who knows, perhaps I have already implemented a PoC or written an article about what you are looking for.

Project Diagram

project diagram

Applications

  • bitcoin-api

    Spring Boot Web Java application service that simulatesBTC price changes and pushes those changes toKafka

  • bitcoin-client

    Spring Boot Web Java application that was implemented usingThymeleaf as HTML template. It reads fromKafka and updates its UI usingWebsocket. It has also a chat where users can talk to each other by sending messages publicly or privately.

Prerequisites

Start Environment

  • Open a terminal and inside thespringboot-kafka-websocket root folder run:

    docker compose up -d
  • Wait for Docker containers to be up and running. To check it, run:

    docker ps -a

Running applications with Maven

Inside thespringboot-kafka-websocket root folder, run the followingMaven commands in different terminals:

  • bitcoin-api

    ./mvnw clean spring-boot:run --projects bitcoin-api -Dspring-boot.run.jvmArguments="-Dserver.port=9081"
  • bitcoin-client

    ./mvnw clean spring-boot:run --projects bitcoin-client -Dspring-boot.run.jvmArguments="-Dserver.port=9082"

Running Applications as Docker containers

Build Application’s Docker Image

  • In a terminal, make sure you are inside thespringboot-kafka-websocket root folder;

  • In order to build the application docker images, run the following script:

    ./build-docker-images.sh

Application’s Environment Variables

  • bitcoin-api

    Environment VariableDescription

    MYSQL_HOST

    Specify host of theMySQL database to use (defaultlocalhost)

    MYSQL_PORT

    Specify port of theMySQL database to use (default3306)

    KAFKA_HOST

    Specify host of theKafka message broker to use (defaultlocalhost)

    KAFKA_PORT

    Specify port of theKafka message broker to use (default29092)

  • bitcoin-client

    Environment VariableDescription

    KAFKA_HOST

    Specify host of theKafka message broker to use (defaultlocalhost)

    KAFKA_PORT

    Specify port of theKafka message broker to use (default29092)

Start Application’s Docker container

  • In a terminal, make sure you are inside thespringboot-kafka-websocket root folder;

  • Run the following script:

    ./start-apps.sh

Applications URLs

ApplicationURLCredentials (user/pass)

bitcoin-api

http://localhost:9081/swagger-ui.html

bitcoin-client

http://localhost:9082

user1/123 oruser2/123

The gif below shows two users checking real-time theBTC price changes. Additionally, they are using a chat channel to communicate with each other.

two users example

Useful Links & Commands

  • Kafdrop

    Kafdrop can be accessed athttp://localhost:9000

  • MySQL

    docker exec -it -e MYSQL_PWD=secret mysql mysql -uroot --database bitcoindbselect * from prices;

Shutdown

  • To stop applications

    • If they were started withMaven, go to the terminals where they are running and pressCtrl+C;

    • If they were started as Docker containers, go to a terminal and, inside thespringboot-kafka-websocket root folder, run the script below:

      ./stop-apps.sh
  • To stop and remove docker compose containers, network and volumes, go to a terminal and, inside thespringboot-kafka-websocket root folder, run the following command:

    docker compose down -v

Cleanup

To remove the Docker images created by this project, go to a terminal and, inside thespringboot-kafka-websocket root folder, run the script below:

./remove-docker-images.sh

About

The goal of this project is to implement two Spring Boot applications: bitcoin-api and bitcoin-client. The bitcoin-api application simulates BTC price changes, while the bitcoin-client application listens to these changes and updates a real-time UI. The bitcoin-client UI is secured using Basic Authentication.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

 

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp