Bird
0
0

Which code snippet correctly demonstrates the use of a circuit breaker pattern in a microservice call?

easy📝 Conceptual Q3 of 15
Microservices - Resilience Patterns
Which code snippet correctly demonstrates the use of a circuit breaker pattern in a microservice call?
A<pre>response = service.call().retry(3).timeout(1000).execute()</pre>
B<pre>response = service.call().circuitBreaker().execute()</pre>
C<pre>response = service.call().bulkhead(5).execute()</pre>
D<pre>response = service.call().fallback(() => defaultResponse).execute()</pre>
Step-by-Step Solution
Solution:
  1. Step 1: Identify circuit breaker usage

    The circuit breaker pattern wraps a call to monitor failures and open the circuit when needed.
  2. Step 2: Analyze options

    response = service.call().circuitBreaker().execute()
    shows a call with circuitBreaker() method, which is correct syntax for circuit breaker usage.
  3. Final Answer:

    response = service.call().circuitBreaker().execute() -> Option B
  4. Quick Check:

    Circuit breaker wraps call [OK]
Quick Trick: Circuit breaker wraps call to monitor failures [OK]
Common Mistakes:
MISTAKES
  • Confusing retry or bulkhead with circuit breaker
  • Using fallback as circuit breaker
  • Missing circuit breaker wrapper

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Microservices Quizzes