The goal of this project is to learn String Integration
. For it, we will implement some Spring Boot
applications and try to use the well-known Enterprise Integration Patterns
.
On ivangfr.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.
-
Spring Boot
Java Web application that exposes an endpoint so that users can submit the operation (addition, subtraction, division or multiplication) they want to perform over two decimal numbersa
andb
.POST /api/calculate -d { "a": number, "b": number, "operation": ["ADD" | "SUBTRACT" | "DIVIDE" | "MULTIPLY"] }
-
Spring Boot
Java Web application that exposes an endpoint so that users can get information about a file. This service keeps looking atshared/files
folder for created or modified files and save their content and info inMongoDB
.GET api/files/{filename}
-
Spring Boot Shell
Java application that has a couple of commands. One is to write some content to a file. Those files are stored inshared/files
folder. Besides, there are some commands that usescalculator-api
to compute the basic Math operations. There is also has a command that callsfile-service
in order to get information about a file. All the communication withcalculator-api
andfile-service
is overHTTP
. Finally, there is a simple command calledgreet
, so that you can display a greeting message on the screen depending on the time of the day.
-
Open a terminal and navigate to
spring-integration-examples
root folder -
Run the following command
docker compose up -d
-
calculator-api
In a terminal and inside
spring-integration-examples
root folder run./mvnw clean spring-boot:run --projects calculator-api
-
file-service
Open a new terminal and inside
spring-integration-examples
root folder runSHARED_FILES_PATH=${PWD}/shared/files ./mvnw clean spring-boot:run --projects file-service
-
spring-integration-shell
Open a new terminal and inside
spring-integration-examples
root folder runSHARED_FILES_PATH=${PWD}/shared/files ./mvnw clean spring-boot:run --projects spring-integration-shell
-
- In a terminal, make sure you are in
spring-integration-examples
root folder - Run the following script to build the Docker images
./docker-build.sh
- In a terminal, make sure you are in
-
-
calculator-api
None
-
file-service
Environment Variable Description MONGODB_HOST
Specify host of the MongoDB
database to use (defaultlocalhost
)MONGODB_PORT
Specify port of the MongoDB
database to use (default27017
) -
spring-integration-shell
Environment Variable Description CALCULATOR_API_HOST
Specify host of the calculator-api
to use (defaultlocalhost
)CALCULATOR_API_PORT
Specify port of the calculator-api
to use (default9080
)FILE_SERVICE_HOST
Specify host of the file-service
to use (defaultlocalhost
)FILE_SERVICE_PORT
Specify port of the file-service
to use (default9081
)
-
-
- In a terminal, make sure you are inside
spring-integration-examples
root folder - Run following command
./start-services.sh && ./start-shell.sh
- In a terminal, make sure you are inside
-
calculator-api
A sample of request to add two numbers
curl -i -X POST http://localhost:9080/api/calculate \ -H 'Content-Type: application/json' \ -d '{"operation": "ADD", "a": 10, "b": 12}'
-
spring-integration-shell
The
spring-integration-shell
UI and a sample of execution -
file-service
A sample of request to get information about a file
curl -i http://localhost:9081/api/files/file.txt
-
MongoDB
Find all files
docker exec -it mongodb mongosh filesdb db.myFiles.find()
Type
exit
to get out ofMongoDB shell
- To stop
spring-integration-shell
, go to the terminal where it is running and typeexit
- To stop
calculator-api
andfile-service
- If you start them with
Maven
, go to the terminals were they are running and pressCtrl+C
- If you start them as Docker containers, go to a terminal and, inside
spring-integration-examples
root folder, run the following script./stop-services.sh
- If you start them with
- To stop and remove
MongoDB
and docker compose network, go to a terminal and, insidespring-integration-examples
root folder, run the command belowdocker compose down -v
To remove the Docker images created by this project, go to a terminal and, inside spring-integration-examples
root folder, run the following script
./remove-docker-images.sh