Spring Cloud Technology & Digital Applications 5 — Questions and Answers
Question 1: Which Spring Cloud Gateway predicate matches requests based on the value of an HTTP header?
- Query predicate
- Header predicate (Correct answer)
- Host predicate
- Cookie predicate
Correct answer: Header predicate
The Header predicate matches routes when a request contains a specified header name and optional regex-matched value.
Question 2: In Spring Cloud, what does the term 'service mesh' integration refer to when using Spring Cloud Kubernetes?
- Replacing Kubernetes DNS with Eureka
- Delegating service-to-service communication and observability to a sidecar proxy like Istio (Correct answer)
- Running Spring Boot inside a Docker Swarm
- Using Spring Cloud Gateway as a Kubernetes Ingress controller
Correct answer: Delegating service-to-service communication and observability to a sidecar proxy like Istio
Service mesh integration offloads cross-cutting concerns (mTLS, retries, tracing) to a sidecar proxy such as Istio or Linkerd running alongside the Spring pod.
Question 3: Which annotation registers a Spring Boot application as a Eureka client and enables service discovery?
- @EnableEurekaServer
- @EnableFeignClients
- @EnableDiscoveryClient (Correct answer)
- @EnableCircuitBreaker
Correct answer: @EnableDiscoveryClient
@EnableDiscoveryClient registers the application with any compatible service registry (Eureka, Consul, Zookeeper) and enables lookup of other services.
Question 4: What Spring Cloud contract testing tool lets a producer define contracts that are automatically turned into consumer-side tests?
- Spring Cloud OpenFeign
- Spring Cloud Contract (Correct answer)
- Spring Cloud Task
- Spring Cloud Sleuth
Correct answer: Spring Cloud Contract
Spring Cloud Contract enables Consumer-Driven Contract testing by generating stubs and verifying producer implementations against shared contracts.
Question 5: How does Spring Cloud LoadBalancer obtain the list of available service instances by default?
- From a static list in application.yml
- From the service discovery registry (e.g., Eureka) (Correct answer)
- From Kubernetes Ingress rules
- From an external Redis cache
Correct answer: From the service discovery registry (e.g., Eureka)
Spring Cloud LoadBalancer queries the service registry to get healthy, currently registered instances before selecting one for a request.
Question 6: Which Spring Cloud Stream feature allows multiple functions to be composed into a processing pipeline?
- Binder chaining
- Function composition using the '|' pipe in spring.cloud.function.definition (Correct answer)
- Stream branching via @Input/@Output chains
- MessageChannel wiring in XML
Correct answer: Function composition using the '|' pipe in spring.cloud.function.definition
Spring Cloud Function's definition property supports function composition with '|' (pipe) notation, e.g., 'uppercase|trim', executed left to right.
Question 7: What is the primary use of the spring.cloud.config.fail-fast=true property on a Config client?
- Causes the client to skip the Config Server if it's slow
- Makes the application fail to start if it cannot connect to Config Server on boot (Correct answer)
- Disables local property fallbacks permanently
- Forces synchronous HTTP calls to the Config Server
Correct answer: Makes the application fail to start if it cannot connect to Config Server on boot
With fail-fast=true, the application throws an exception and refuses to start if Config Server is unreachable, preventing misconfigured deployments.
Which Spring Cloud Gateway predicate matches requests based on the value of an HTTP header?