0
0
RabbitMQdevops~10 mins

RPC vs direct API calls in RabbitMQ - Interactive Practice

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

Complete the code to send a message to the queue named 'task_queue'.

RabbitMQ
channel.basic_publish(exchange='', routing_key='[1]', body='Hello World!')
Drag options to blanks, or click blank then click option'
Atask_queue
Brpc_queue
Capi_queue
Dresponse_queue
Attempts:
3 left
💡 Hint
Common Mistakes
Using the wrong queue name in routing_key
Confusing exchange with routing_key
2fill in blank
medium

Complete the code to declare a queue for RPC server to listen on.

RabbitMQ
channel.queue_declare(queue='[1]')
Drag options to blanks, or click blank then click option'
Atask_queue
Brpc_queue
Capi_queue
Dcallback_queue
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'task_queue' instead of 'rpc_queue'
Confusing callback queue with server queue
3fill in blank
hard

Fix the error in the code to send an RPC request with a unique correlation id.

RabbitMQ
channel.basic_publish(exchange='', routing_key='rpc_queue', properties=pika.BasicProperties(correlation_id=[1]), body='Request')
Drag options to blanks, or click blank then click option'
A'corr_id_1'
B'12345'
C12345
DNone
Attempts:
3 left
💡 Hint
Common Mistakes
Using an integer instead of a string for correlation_id
Passing None as correlation_id
4fill in blank
hard

Fill both blanks to create a dictionary comprehension that filters messages with a correlation id matching the request.

RabbitMQ
responses = {k: v for k, v in messages.items() if k [1] request_id and v [2] 'done'}
Drag options to blanks, or click blank then click option'
A==
B!=
Attempts:
3 left
💡 Hint
Common Mistakes
Using '!=' instead of '=='
Mixing operators incorrectly
5fill in blank
hard

Fill all three blanks to create a dictionary comprehension that maps request IDs to their responses if the response status is 'success'.

RabbitMQ
result = [1]: [2] for [3] in responses.items() if v == 'success'
Drag options to blanks, or click blank then click option'
Areq_id
Bresp
Creq_id, v
Dv
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing key and value names
Incorrect unpacking of items
Using wrong variable names