Status: Accepted Date: 2025-12-13
This application consumes the quote service. We need to decide when and how to call the quote service and return the result.
Options considered:
- Fetch on startup using
ApplicationRunner(original guide pattern) - Expose a REST endpoint that fetches on demand
- Use a scheduled task
Expose a /quote endpoint that fetches a random quote from the backend on demand.
Option 1 (ApplicationRunner) is rejected for this module in favor of a normal REST endpoint.
This approach is more practical than the original guide's ApplicationRunner pattern:
- The application stays running as a web server
- Users can fetch quotes whenever they want by calling
/quote - Easier to test and demonstrate
- More representative of real-world service-to-service calls
The consumer runs on port 8081 (configured in application.properties) and calls the quote-service on port 8080.
Easier:
- Application stays running, can be called repeatedly
- More realistic microservice pattern
- Easier to test with curl or browser
- No timing issues (quote-service just needs to be running)
Harder:
- Differs from the original Spring guide (which uses ApplicationRunner)
- Requires understanding of both provider and consumer as web services