Complete the code to show a synchronous call between services.
response = serviceA.call_serviceB([1])In synchronous communication, the caller sends a request and waits for the response before continuing.
Complete the code to send an asynchronous message.
message_queue.[1](event)Publishing an event to a message queue is an asynchronous way to communicate between services.
Fix the error in the synchronous call to avoid blocking indefinitely.
response = serviceA.call_serviceB(timeout=[1])Setting a timeout (e.g., 30 seconds) prevents the caller from blocking forever if the service does not respond.
Fill both blanks to create an asynchronous event handler that processes messages.
def handle_event(event): [1] = event.get('data') process([2])
The handler extracts 'data' from the event and processes it asynchronously.
Fill all three blanks to implement a retry mechanism for synchronous calls.
for attempt in range([1]): try: response = service.call() if response.status == [2]: break except [3]: continue
Retry up to 3 times, break if HTTP 200 OK received, and catch timeout errors to retry.