Guided Exercise - Principles of Microservices (With Twelve Factor Addendum) - Online Bookstore System #175
Replies: 4 comments 1 reply
|
Hi Akash, Please find below the completion status:
Enhancing the above code for circuit breaker pattern. Circuit breaker to be tested yet. Using this section to upload intermediate code version |
|
Hi Akash, I have sent you the link to repo for the 4 microservices. The junit test is added for Order service only. Rest of the features have been added in all other microservices. The swagger endpoints are: Regards |
|
Expanding the Online Bookstore System exercise to include the Twelve-Factor App methodology provides a comprehensive framework for building scalable and maintainable applications. Below is an explanation of each factor, its importance for the Online Bookstore System, implementation strategies, benefits, drawbacks, and how they integrate with the principles of microservice architecture. 1. Codebase
2. Dependencies
3. Config
4. Backing Services
5. Build, Release, Run
6. Processes
7. Port Binding
8. Concurrency
9. Disposability
10. Dev/Prod Parity
11. Logs
12. Admin Processes
Integration with Microservice Principles
Implementing the Twelve-Factor App methodology alongside the principles of microservice architecture in the Online Bookstore System exercise provides a comprehensive learning experience, illustrating best practices in modern application development. To transform the integration of the Twelve-Factor App methodology with the principles of microservice architecture into a structured exercise for the Online Bookstore System, we'll outline specific tasks and provide implementation guidelines for each factor. This exercise will help in gaining hands-on experience and a deeper understanding of building scalable and resilient microservices. Exercise OutlineTask 1: Implement Codebase Factor
Task 2: Manage Dependencies
Task 3: Configuration Management
Task 4: Backing Services as Resources
Task 5: Separate Build, Release, Run
Task 6: Stateless Processes
Task 7: Port Binding
Task 8: Concurrency Through Process Model
Task 9: Fast Startup and Graceful Shutdown
Task 10: Dev/Prod Parity
Task 11: Logs as Event Streams
Task 12: Admin Processes as Jobs
Integration with Microservice Principles
ConclusionThis exercise is designed to provide practical experience in implementing the Twelve-Factor App methodology in a microservice architecture. The tasks will guide you through each factor, helping you understand their application and impact on a real-world project like the Online Bookstore System. This comprehensive approach ensures a well-rounded learning experience in modern software architecture and development practices. |
|
Hi @akash-coded , Sharing my code in zip file for Guided Exercise - Principles of Microservices (With Twelve Factor Addendum) with Logback and Actuator |
Uh oh!
There was an error while loading. Please reload this page.
This exercise will be scenario-based, leveraging only Spring Boot concepts, JPA with an H2 database, Rest Template, Feign Client, SLF4J with Logback for logging, and Spring Actuator. The exercise is designed to be complex yet understandable and should take a learner a day or more to complete.
Scenario: Online Bookstore System
Overview:
You are tasked with developing an Online Bookstore System using a microservice architecture. The system will consist of several independent microservices communicating with each other.
Services:
Exercise Objectives:
Principles & Tasks:
Single Responsibility: Each microservice (Book, Order, User, Review) must have a single responsibility and operate independently.
Loose Coupling: Services should be loosely coupled. Implement APIs for communication between services using Rest Template and Feign Client.
Service Autonomy: Ensure each service is autonomous and can operate independently of others.
Service Discoverability: Implement API documentation using Swagger for easy discoverability.
Scalability: Design each service to handle varying loads, demonstrating horizontal scaling.
Fault Tolerance: Handle failures gracefully. Implement basic fallback methods in Feign Clients.
Data Isolation: Each service should have its own database schema in H2.
Evolutionary Design: Design your microservices to be open for extension but closed for modification.
Implementation Steps:
Setup Basic Structure:
Define Models and Repositories:
Create Service APIs:
Inter-Service Communication:
Logging and Monitoring:
API Documentation:
Testing:
Execution and Observation:
Deliverables:
This exercise provides a hands-on experience with the core principles of microservice architecture using Spring Boot, promoting a deep understanding of the subject.
Continuing with the elaboration on each principle of microservice architecture, I'll explain what each principle is, why it's important for our Online Bookstore System, how to implement it, and the benefits and drawbacks. At the end, I'll highlight how all these principles work together.
1. Single Responsibility
2. Loose Coupling
3. Service Autonomy
4. Service Discoverability
5. Scalability
6. Fault Tolerance
7. Data Isolation
8. Evolutionary Design
Integrating the Principles:
In conclusion, each principle plays a critical role in the architecture of the Online Bookstore System. While they each have their benefits and drawbacks, together they form a harmonious and efficient microservice ecosystem, showcasing the power of a well-structured microservice architecture.
Below are step-by-step instructions, including hints, code snippets, repository structure, dependencies, and configurations for each service.
General Setup
Repository Structure
OnlineBookstoreBookServiceOrderServiceUserServiceReviewServiceCommon Dependencies (for all services)
Include these in your
pom.xml(for Maven) orbuild.gradle(for Gradle):Application Properties
application.propertiesfor each service with appropriate server port, database configurations, and logging settings.Book Service
Tasks & Hints
Bookentity and repository.Code Snippet
Order Service
Tasks & Hints
Orderentity and repository.Code Snippet
User Service
Tasks & Hints
Userentity and repository.Code Snippet
Review Service
Tasks & Hints
Reviewentity and repository.Code Snippet
Common Configurations
Logging (logback.xml)
logback.xmlfor logging format and levels.Swagger Configuration
Building and Running
Additional Hints
Conclusion
Following these steps will give you a hands-on experience in building a microservice architecture using Spring Boot. Each service should be developed and tested individually before integrating them to form the complete system. Remember, the key is to understand the principles behind each task and how they contribute to a robust microservice architecture.
All reactions