this is a simple project built using spring boot, where I implement the following technologies:
- Grpc for synchronous calls between microservices.
- Kafka for queued messages.
- a user microservice to create, get and delete users.
- a post microservice to create, list, get.
- a maven project that contains the .proto file to generate an interface containing messages and services. this interface is used as a dependency in both microservices.
url | method | description |
---|---|---|
/users | GET | get all users |
/users/{user} | GET | get a user by its id |
/users/{user} | DELETE | delete a user by its id |
url | method | description |
---|---|---|
/posts/{post} | GET | get a post by its id |
/posts | POST | create a post |
/users/{user}/posts/{post} | GET | get a post of a specific user |
used for synchronous call between the post microservice and the user service, where the post microservice sends a request to the user microservice to check if a user exists when the /users/{user}/posts/{post}
route is called.
communication is occured using the generated interface.
service UserService {
rpc getUserById(UserEntityRequest) returns (UserEntityResponse) {};
}
when a user is deleted, a producer generates a message with user-deleted
topic that will be intercepted by a consumer in the post microservice. this one will delete all user's posts.