Spring Cloud Professional Standards & Competencies 2 — Questions and Answers
Question 1: Which Spring Cloud component implements the Circuit Breaker pattern to prevent cascading failures?
- Spring Cloud Sleuth
- Spring Cloud Circuit Breaker (Resilience4j) (Correct answer)
- Spring Cloud Bus
- Spring Cloud Stream
Correct answer: Spring Cloud Circuit Breaker (Resilience4j)
Spring Cloud Circuit Breaker provides an abstraction over Resilience4j to stop cascading failures by opening a circuit when error thresholds are breached.
Question 2: What is the recommended approach for externalizing configuration in a Spring Cloud microservices environment?
- Hardcode values in application.properties
- Use Spring Cloud Config Server backed by a Git repository (Correct answer)
- Store configuration in the database
- Pass configuration as JVM system properties only
Correct answer: Use Spring Cloud Config Server backed by a Git repository
Spring Cloud Config Server with a Git-backed repository is the recommended approach for centralizing and versioning configuration across microservices.
Question 3: A developer needs distributed tracing across multiple microservices. Which Spring Cloud tool assigns a unique trace ID to a request?
- Spring Cloud Gateway
- Spring Cloud Sleuth / Micrometer Tracing (Correct answer)
- Spring Cloud Consul
- Spring Cloud Task
Correct answer: Spring Cloud Sleuth / Micrometer Tracing
Spring Cloud Sleuth (now Micrometer Tracing) automatically assigns trace and span IDs to requests, enabling end-to-end distributed tracing.
Question 4: Which professional best practice should guide the naming of Spring Cloud Config Server profiles?
- Use numeric IDs for each environment
- Use meaningful environment names like dev, staging, and prod (Correct answer)
- Name profiles after the developer who owns them
- Use random UUIDs to avoid collisions
Correct answer: Use meaningful environment names like dev, staging, and prod
Using meaningful environment names (dev, staging, prod) makes configuration management understandable and maintainable across teams.
Question 5: What does the @EnableDiscoveryClient annotation signify in a Spring Cloud application?
- Enables OAuth2 resource discovery
- Registers the service with a discovery server like Eureka or Consul (Correct answer)
- Enables config server auto-refresh
- Activates API gateway routing
Correct answer: Registers the service with a discovery server like Eureka or Consul
@EnableDiscoveryClient marks the application to register itself with and discover other services via a service registry such as Eureka or Consul.
Question 6: Which principle governs how Spring Cloud Gateway should handle authentication for downstream microservices?
- Each microservice should independently authenticate every request
- Authentication should be centralized at the gateway, passing identity downstream (Correct answer)
- Downstream services should re-authenticate using separate credentials
- Authentication is handled only by the database layer
Correct answer: Authentication should be centralized at the gateway, passing identity downstream
Best practice places authentication at the API gateway layer, which then propagates authenticated identity (e.g., via JWT) to downstream services.
Question 7: When using Spring Cloud Bus, what is its primary professional use case?
- Routing HTTP requests between services
- Broadcasting configuration refresh events across all service instances (Correct answer)
- Storing distributed state in a shared cache
- Providing service health dashboards
Correct answer: Broadcasting configuration refresh events across all service instances
Spring Cloud Bus connects all instances via a message broker (Kafka or RabbitMQ) to broadcast events like config refreshes, eliminating manual restarts.
Which Spring Cloud component implements the Circuit Breaker pattern to prevent cascading failures?