Spring Cloud Test 2

    Question 1SERVICE DISCOVERY - Default Port for Eureka Server

    By default, on which port does a Eureka Server run?

    Question 2API GATEWAY - Predicates in Routing

    What do Predicates in Spring Cloud Gateway define?

    Question 3CENTRALIZED CONFIG - Config Client Setup

    Which file is typically used by a Config Client to connect to the Config Server?

    Question 4CIRCUIT BREAKEER - Code Snippet (Config in application.yml)

    What does the following config do?

    resilience4j.circuitbreaker: instances: orderService: failureRateThreshold: 50 waitDurationInOpenState: 10s

    Question 5DISTRIBUTED TRACING - Micrometer Metrics Purpose

    What is Micrometer used for in Spring Boot?

    Question 6SERVICE DISCOVERY - application.properties (Eureka Client)

    What does this configuration achieve?

    spring.application.name=order-service eureka.client.service-url.defaultZone=http://localhost:8761/eureka/

    Question 7API GATEWAY - Code Snippet (Header Predicate)

    What does this config enforce?

    spring: cloud: gateway: routes: - id: auth_route uri: http://localhost:8082 predicates: - Header=X-Auth-Token, .+

    Question 8CENTRALIZED CONFIG - Code Snippet (Client bootstrap.yml)

    What does this configuration do?

    spring: cloud: config: uri: http://localhost:8888 application: name: order-service

    Question 9RESILIENCE - Retry Mechanism

    In Resilience4j, what does the `@Retry` annotation do?

    Question 10DISTRIBUTED TRACING - Code Snippet (Custom Span)

    What does this snippet do?

    @Autowired Tracer tracer; public void processPayment() { Span newSpan = tracer.nextSpan().name("payment-span"); try (Tracer.SpanInScope ws = tracer.withSpan(newSpan.start())) { // business logic here } finally { newSpan.end(); } }

    Question 11SERVICE DISCOVERY - @LoadBalanced in RestTemplate

    What does the @LoadBalanced annotation do for a RestTemplate bean in a Eureka-enabled Spring Boot app?

    Question 12API GATEWAY - Filters

    What is the purpose of filters in Spring Cloud Gateway?

    Question 13CENTRALIZED CONFIG - Profiles & Labels

    If a service named order-service runs with profile dev, which file will Config Server serve?

    Question 14CIRCUIT BREAKEER - Code Snippet (Retry Example)

    What is the effect of this snippet?

    @Retry(name = "paymentRetry", fallbackMethod = "paymentFallback") public String processPayment() { return paymentClient.pay(); }

    Question 15DISTRIBUTED TRACING - Auto-Instrumentation

    How does Spring Cloud Sleuth instrument HTTP requests automatically?

    Question 16SERVICE DISCOVERY - Code Snippet (Inter-Service Call)

    What does the following code achieve?

    @Autowired private RestTemplate restTemplate; public String callPayment() { return restTemplate.getForObject("http://payment-service/pay", String.class); }

    Question 17API GATEWAY - Code Snippet (Add Request Header Filter)

    What does this filter configuration do?

    spring: cloud: gateway: routes: - id: log_route uri: http://localhost:8083 predicates: - Path=/logs/** filters: - AddRequestHeader=X-App-Name, GatewayService

    Question 18CENTRALIZED CONFIG - Refreshing Config at Runtime

    How do you make a Spring Boot bean refreshable when config values change in Config Server?

    Question 19RESILIENCE - Bulkhead Pattern

    What does the Bulkhead feature in Resilience4j achieve?

    Question 20DISTRIBUTED TRACING - Code Snippet (Micrometer Counter)

    What does this snippet achieve?

    @Autowired MeterRegistry registry; public void incrementOrders() { registry.counter("orders.processed").increment(); }