0
0
Microservicessystem_design~10 mins

Synchronous vs asynchronous communication in Microservices - Interactive Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to show a synchronous call between services.

Microservices
response = serviceA.call_serviceB([1])
Drag options to blanks, or click blank then click option'
Await_for_response
Bfire_and_forget
Csend_request_and_wait
Dpublish_event
Attempts:
3 left
💡 Hint
Common Mistakes
Choosing 'fire_and_forget' which is asynchronous behavior.
2fill in blank
medium

Complete the code to send an asynchronous message.

Microservices
message_queue.[1](event)
Drag options to blanks, or click blank then click option'
Apublish_event
Bsend_request_and_wait
Ccall_service
Dwait_for_response
Attempts:
3 left
💡 Hint
Common Mistakes
Using synchronous call methods instead of event publishing.
3fill in blank
hard

Fix the error in the synchronous call to avoid blocking indefinitely.

Microservices
response = serviceA.call_serviceB(timeout=[1])
Drag options to blanks, or click blank then click option'
A-1
B0
CNone
D30
Attempts:
3 left
💡 Hint
Common Mistakes
Using None or zero which may cause indefinite blocking.
4fill in blank
hard

Fill both blanks to create an asynchronous event handler that processes messages.

Microservices
def handle_event(event):
    [1] = event.get('data')
    process([2])
Drag options to blanks, or click blank then click option'
Adata
Bevent_data
Devent
Attempts:
3 left
💡 Hint
Common Mistakes
Using different variable names causing undefined errors.
5fill in blank
hard

Fill all three blanks to implement a retry mechanism for synchronous calls.

Microservices
for attempt in range([1]):
    try:
        response = service.call()
        if response.status == [2]:
            break
    except [3]:
        continue
Drag options to blanks, or click blank then click option'
A3
B200
CTimeoutError
D5
Attempts:
3 left
💡 Hint
Common Mistakes
Using too many retries or wrong exception types.