The goal of this project is to implement two String Boot
applications, bitcoin-api
and bitcoin-client
. The first simulates BTC
price changes and, the second, will listen from those changes and update a UI at real-time.
-
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 comments publicly or privately.
-
Open a terminal and inside
springboot-kafka-websocket
root folder rundocker-compose up -d
-
Wait for Docker containers to be up and running. To check it, run
docker-compose ps
Inside springboot-kafka-websocket
root folder, run the following Maven
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"
-
In a terminal, make sure you are in
springboot-kafka-websocket
root folder -
In order to build the application docker images, run the following script
./docker-build.sh
-
bitcoin-api
Environment Variable Description MYSQL_HOST
Specify host of the
MySQL
database to use (defaultlocalhost
)MYSQL_PORT
Specify port of the
MySQL
database to use (default3306
)KAFKA_HOST
Specify host of the
Kafka
message broker to use (defaultlocalhost
)KAFKA_PORT
Specify port of the
Kafka
message broker to use (default29092
)ZIPKIN_HOST
Specify host of the
Zipkin
distributed tracing system to use (defaultlocalhost
)ZIPKIN_PORT
Specify port of the
Zipkin
distributed tracing system to use (default9411
) -
bitcoin-client
Environment Variable Description KAFKA_HOST
Specify host of the
Kafka
message broker to use (defaultlocalhost
)KAFKA_PORT
Specify port of the
Kafka
message broker to use (default29092
)ZIPKIN_HOST
Specify host of the
Zipkin
distributed tracing system to use (defaultlocalhost
)ZIPKIN_PORT
Specify port of the
Zipkin
distributed tracing system to use (default9411
)
-
In a terminal, make sure you are inside
springboot-kafka-websocket
root folder -
Run following script
./start-apps.sh
-
Wait for application’s Docker containers to be up and running. To check it, run
docker ps -f name=bitcoin-api -f name=bitcoin-client
Application | URL | Credentials (user/pass) |
---|---|---|
bitcoin-api |
||
bitcoin-client |
|
The gif below shows two users checking real-time the BTC
price changes. Besides, they are using a chat channel to
communicate with each other.
-
Zipkin
Zipkin
can be accessed at http://localhost:9411 -
Kafka Topics UI
Kafka Topics UI
can be accessed at http://localhost:8085 -
Kafka Manager
Kafka Manager
can be accessed at http://localhost:9000Configuration
-
First, you must create a new cluster. Click on
Cluster
(dropdown button on the header) and then onAdd Cluster
-
Type the name of your cluster in
Cluster Name
field, for example:MyCluster
-
Type
zookeeper:2181
inCluster Zookeeper Hosts
field -
Enable checkbox
Poll consumer information (Not recommended for large # of consumers if ZK is used for offsets tracking on older Kafka versions)
-
Click on
Save
button at the bottom of the page.
-
-
MySQL
docker exec -it mysql mysql -uroot -psecret --database=bitcoindb select * from prices;
-
To stop applications
-
If they were started with
Maven
, go to the terminals where they are running and pressCtrl+C
-
If they were started as Docker containers, go to a terminal and, inside
springboot-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
springboot-kafka-websocket
root folder, run the following commanddocker-compose down -v