In lab 2, we will implement several microservices that together form the backend for a chat program. The focus is on configuring and running multiple microservices together effectively. This involves participating in the development of such a service as well as using others' services to create a functioning system. Microservices do not need to be written using Spring Boot but can be implemented using, for example, Quarkus, Micronaut, or perhaps another programming language other than Java.
Services from 2023 are available on repositories (github.com), and this is where you will also place your implementations together with CI/CD pipelines.
Develop one of the examples of microservices listed below. The microservice should be externally configurable and stateless (no session) to enable horizontal scaling. Any state should be stored in the associated database. The service should be available as a Docker image along with necessary documentation on how to run it.
During the last week of the course, demonstrate your own microservice and someone else's published service by starting them in Docker with docker-compose or in Kubernetes.
The Post Service is responsible for storing messages along with their associated information. This service allows users to send and receive messages within the chat application.
- Store messages: The service should provide endpoints to store messages along with metadata such as sender, recipient, timestamp, etc.
- Retrieve messages: Users should be able to retrieve stored messages based on various criteria such as sender, recipient, time range, etc.
requires MongoDB
runs on port 8090
docker pull ghcr.io/chatgut/post-service-aj:main
docker network create mynetwork
docker run -d --name mongodb --network=mynetwork -p 27017:27017 mongo:latest
docker run -d --name postapp --network=mynetwork -p 8090:8080 --env SPRING_DATA_MONGODB_URI=mongodb://mongodb:27017/messages ghcr.io/chatgut/post-service-aj:main
These commands will pull the latest image of post-service and build the service postapp together with mongodb.
-
This endpoint retrieves all messages from the database. It doesn't require any parameters.
http://localhost:8090/messages
-
This endpoint retrieves a single message by its ID. Replace {id} with the ID of the message you want to retrieve.
http://localhost:8090/messages/123
This endpoint facilitates the creation of a new message within the system. It requires a JSON body containing the message details and a userId header.
Example:
- Request:
- URL:
http://localhost:8090/messages - Method: POST
- Headers:
userId: 123
- Body:
{ "msgContent": "Hello, world!" }
- URL:
-
This endpoint deletes a message by its ID. Replace {id} with the ID of the message you want to delete.
http://localhost:8090/messages/123
- Jens Nilsson (@[email protected])
- August Rydnell (@[email protected])