0
0
RabbitMQdevops~10 mins

Timeout handling in RPC in RabbitMQ - Interactive Code Practice

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

Complete the code to set a timeout for the RPC call.

RabbitMQ
channel.basic_publish(exchange='', routing_key='rpc_queue', properties=pika.BasicProperties(reply_to=callback_queue, correlation_id=corr_id), body=request_body)
channel.connection.process_data_events(time_limit=[1])
Drag options to blanks, or click blank then click option'
A5
B-1
C0
D10
Attempts:
3 left
💡 Hint
Common Mistakes
Using 0 or negative values disables the timeout.
2fill in blank
medium

Complete the code to raise an exception if the RPC response is not received in time.

RabbitMQ
if response is None:
    raise [1]('RPC call timed out')
Drag options to blanks, or click blank then click option'
ATimeoutError
BValueError
CKeyError
DRuntimeError
Attempts:
3 left
💡 Hint
Common Mistakes
Using exceptions unrelated to timeouts like ValueError.
3fill in blank
hard

Fix the error in the code to correctly check the correlation ID in the RPC response.

RabbitMQ
if props.correlation_id != [1]:
    return
Drag options to blanks, or click blank then click option'
AcorrelationId
Bcorr_id
CcorrId
Dcorrelation_id
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect variable names that cause NameError.
4fill in blank
hard

Fill both blanks to set up the callback queue and consume messages with a timeout.

RabbitMQ
result = channel.queue_declare(queue='', exclusive=True)
callback_queue = result.[1]
channel.basic_consume(queue=callback_queue, on_message_callback=[2], auto_ack=True)
Drag options to blanks, or click blank then click option'
Amethod.queue
Bcallback
Cqueue
Dconsume
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong attribute names causing AttributeError.
5fill in blank
hard

Fill all three blanks to create a dictionary comprehension that filters responses received within the timeout.

RabbitMQ
responses = {corr_id: body for corr_id, body in messages.items() if body is not None and corr_id [1] [2]
Drag options to blanks, or click blank then click option'
Ain
Btimeout
Cvalid_ids
Dand
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong operators causing syntax errors.