0
0
RabbitMQdevops~10 mins

Why producer-consumer is the basic messaging pattern in RabbitMQ - Test Your Understanding

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'
Amessage_queue
Bexchange
Crouting_key
Dtask_queue
Attempts:
3 left
💡 Hint
Common Mistakes
Using exchange name instead of queue name
Using routing key as queue name
2fill in blank
medium

Complete the code to publish a message 'Hello World!' to the '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
Bexchange
Cmessage
Dqueue_name
Attempts:
3 left
💡 Hint
Common Mistakes
Using exchange name as routing_key
Using a wrong queue name
3fill in blank
hard

Fix the error in the consumer code to receive messages from 'task_queue'.

RabbitMQ
channel.basic_consume(queue='[1]', on_message_callback=callback, auto_ack=True)
Drag options to blanks, or click blank then click option'
Aexchange
Bmessage_queue
Ctask_queue
Drouting_key
Attempts:
3 left
💡 Hint
Common Mistakes
Using exchange name instead of queue
Using routing_key instead of queue
4fill in blank
hard

Fill both blanks to create a basic producer-consumer pattern: declare queue and publish message.

RabbitMQ
channel.queue_declare(queue='[1]')
channel.basic_publish(exchange='', routing_key='[2]', body='Task message')
Drag options to blanks, or click blank then click option'
Atask_queue
Bexchange
Drouting_key
Attempts:
3 left
💡 Hint
Common Mistakes
Using different names for queue and routing_key
Confusing exchange with queue name
5fill in blank
hard

Fill all three blanks to complete the consumer setup: declare queue, consume messages, and start consuming.

RabbitMQ
channel.queue_declare(queue='[1]')
channel.basic_consume(queue='[2]', on_message_callback=callback, auto_ack=True)
channel.[3]()
Drag options to blanks, or click blank then click option'
Atask_queue
Cstart_consuming
Dconsume_messages
Attempts:
3 left
💡 Hint
Common Mistakes
Using different queue names
Using wrong method to start consuming