0
0
Microservicessystem_design~10 mins

Request-response vs event-driven 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 request-response call between two microservices.

Microservices
response = serviceB.[1](request_data)
Drag options to blanks, or click blank then click option'
Asend_event
Bemit_signal
Cpublish_message
Dcall_api
Attempts:
3 left
💡 Hint
Common Mistakes
Choosing event-driven terms like 'send_event' instead of direct call.
2fill in blank
medium

Complete the code to publish an event in an event-driven microservice.

Microservices
event_bus.[1](event_data)
Drag options to blanks, or click blank then click option'
Arequest_response
Bpublish_event
Ccall_api
Dsend_request
Attempts:
3 left
💡 Hint
Common Mistakes
Using synchronous call terms like 'call_api' in event-driven context.
3fill in blank
hard

Fix the error in the event-driven consumer code to properly handle incoming events.

Microservices
def on_event_received(event):
    [1](event.data)

# Missing function to process event data
Drag options to blanks, or click blank then click option'
Aemit_signal
Bcall_api
Cprocess_event
Dsend_event
Attempts:
3 left
💡 Hint
Common Mistakes
Using sending functions instead of processing functions.
4fill in blank
hard

Fill both blanks to complete the request-response flow: client sends request and waits for response.

Microservices
response = client.[1](request)
if response.[2] == 200:
    handle_success(response.data)
Drag options to blanks, or click blank then click option'
Asend_request
Bstatus_code
Cevent_type
Dpublish_event
Attempts:
3 left
💡 Hint
Common Mistakes
Using event-driven terms in request-response code.
5fill in blank
hard

Fill all three blanks to complete the event-driven consumer that subscribes, processes, and acknowledges events.

Microservices
event_bus.[1]('order_created', on_order)

def on_order(event):
    [2](event.data)
    event.[3]()
Drag options to blanks, or click blank then click option'
Asubscribe
Bprocess_order
Cacknowledge
Dpublish
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'publish' instead of 'subscribe' or 'acknowledge'.