0
0
RabbitMQdevops~10 mins

Batch publishing for throughput 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 'task_queue' in RabbitMQ.

RabbitMQ
channel.queue_declare(queue=[1])
Drag options to blanks, or click blank then click option'
A'task_queue'
Btask_queue
C'queue_task'
Dqueue_task
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting quotes around the queue name
Using incorrect queue name
2fill in blank
medium

Complete the code to publish a message 'Hello' to the 'task_queue'.

RabbitMQ
channel.basic_publish(exchange='', routing_key=[1], body='Hello')
Drag options to blanks, or click blank then click option'
A'queue_task'
Btask_queue
C'hello'
D'task_queue'
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong queue name
Omitting quotes around routing_key
3fill in blank
hard

Fix the error in the batch publishing code by completing the blank.

RabbitMQ
channel.confirm_select()
for message in messages:
    channel.basic_publish(exchange='', routing_key='task_queue', body=message)
channel.[1]()
Drag options to blanks, or click blank then click option'
Await_for_confirms
Bwait_for_ack
Cwait_for_confirms_or_die
Dwait
Attempts:
3 left
💡 Hint
Common Mistakes
Using non-existent method names
Not waiting for confirms after publishing
4fill in blank
hard

Fill both blanks to create a batch publish loop that confirms messages.

RabbitMQ
channel.[1]()
for msg in batch:
    channel.basic_publish(exchange='', routing_key='task_queue', body=msg)
channel.[2]()
Drag options to blanks, or click blank then click option'
Aconfirm_select
Bbasic_publish
Cwait_for_confirms_or_die
Dqueue_declare
Attempts:
3 left
💡 Hint
Common Mistakes
Not enabling confirm mode
Not waiting for confirms after publishing
5fill in blank
hard

Fill all three blanks to create a dictionary comprehension that batches messages by length greater than 5.

RabbitMQ
batched = {msg[1]2: msg for msg in messages if len(msg) [2] 5 and msg [3] 'error'}
Drag options to blanks, or click blank then click option'
A**
B>
C!=
D==
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong operators
Confusing equality and inequality