0
0
RabbitMQdevops~10 mins

Request-reply pattern 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 declare a queue named 'rpc_queue' in RabbitMQ.

RabbitMQ
channel.queue_declare(queue='[1]')
Drag options to blanks, or click blank then click option'
Ahello
Blogs
Ctask_queue
Drpc_queue
Attempts:
3 left
💡 Hint
Common Mistakes
Using a different queue name like 'task_queue' or 'hello' which is not for RPC.
2fill in blank
medium

Complete the code to send a message with a unique correlation_id for the RPC request.

RabbitMQ
channel.basic_publish(exchange='', routing_key='rpc_queue', properties=pika.BasicProperties(correlation_id='[1]'), body='Hello')
Drag options to blanks, or click blank then click option'
Acorr_id_abc
Bunique_id_1
C12345
Drequest_1
Attempts:
3 left
💡 Hint
Common Mistakes
Using non-unique or numeric IDs that don't help match replies.
3fill in blank
hard

Fix the error in the code to consume messages from the callback queue with auto_ack enabled.

RabbitMQ
channel.basic_consume(queue='[1]', on_message_callback=on_response, auto_ack=True)
Drag options to blanks, or click blank then click option'
Areply_queue
Bcallback_queue
Cresponse_queue
Drpc_queue
Attempts:
3 left
💡 Hint
Common Mistakes
Using the request queue name instead of the callback queue.
4fill in blank
hard

Fill both blanks to create a dictionary comprehension that filters messages with correlation_id matching 'corr_id_abc'.

RabbitMQ
filtered = {k: v for k, v in messages.items() if k [1] '[2]'}
Drag options to blanks, or click blank then click option'
A==
Bcorr_id_abc
C!=
Drequest_id
Attempts:
3 left
💡 Hint
Common Mistakes
Using '!=' instead of '==' or wrong string for correlation id.
5fill in blank
hard

Fill all three blanks to create a dictionary comprehension that maps message IDs to bodies for messages with body length greater than 5.

RabbitMQ
result = { [1]: [2] for [3], [2] in messages.items() if len([2]) > 5 }
Drag options to blanks, or click blank then click option'
Amsg_id
Bbody
Dmsg
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing variable names or using inconsistent keys and values.