0
0
RabbitMQdevops~10 mins

Consuming messages 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 consume a message from the queue.

RabbitMQ
channel.basic_consume(queue='task_queue', on_message_callback=[1], auto_ack=True)
Drag options to blanks, or click blank then click option'
Acallback_function
Bconnect_queue
Csend_message
Ddeclare_queue
Attempts:
3 left
💡 Hint
Common Mistakes
Using a function that sends messages instead of processing them.
Passing a queue name instead of a function.
2fill in blank
medium

Complete the code to start consuming messages.

RabbitMQ
channel.[1]()
Drag options to blanks, or click blank then click option'
Aqueue_declare
Bbasic_publish
Cstop_consuming
Dstart_consuming
Attempts:
3 left
💡 Hint
Common Mistakes
Using basic_publish which sends messages instead of receiving.
Calling stop_consuming which stops the consumer.
3fill in blank
hard

Fix the error in the callback function to acknowledge the message.

RabbitMQ
def callback(ch, method, properties, body):
    print(f"Received {body}")
    ch.basic_ack(delivery_tag=[1])
Drag options to blanks, or click blank then click option'
Amethod.delivery_tag
Bbody
Cproperties.delivery_tag
Dch.delivery_tag
Attempts:
3 left
💡 Hint
Common Mistakes
Using the message body as the delivery tag.
Trying to access delivery_tag from the wrong parameter.
4fill in blank
hard

Fill both blanks to consume messages with manual acknowledgment.

RabbitMQ
channel.basic_consume(queue=[1], on_message_callback=[2], auto_ack=False)
Drag options to blanks, or click blank then click option'
A'task_queue'
Bcallback
C'logs'
Dsend_message
Attempts:
3 left
💡 Hint
Common Mistakes
Using a wrong queue name.
Passing a function that does not process messages.
5fill in blank
hard

Fill all three blanks to set up a consumer with a callback and start consuming.

RabbitMQ
channel.basic_consume(queue=[1], on_message_callback=[2], auto_ack=[3])
channel.start_consuming()
Drag options to blanks, or click blank then click option'
A'task_queue'
Bcallback
CFalse
DTrue
Attempts:
3 left
💡 Hint
Common Mistakes
Setting auto_ack to True when manual ack is needed.
Using wrong queue or callback names.