0
0
RabbitMQdevops~10 mins

Publishing 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 declare a queue named 'task_queue'.

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

Complete the code to publish a message 'Hello World!' to the default exchange with routing key 'task_queue'.

RabbitMQ
channel.basic_publish(exchange=[1], routing_key='task_queue', body='Hello World!')
Drag options to blanks, or click blank then click option'
A'task_queue'
B''
C'default'
DNone
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'default' as exchange name instead of empty string.
Using None or queue name as exchange.
3fill in blank
hard

Fix the error in the code to publish a persistent message to 'task_queue'.

RabbitMQ
channel.basic_publish(exchange='', routing_key='task_queue', body='Hello World!', properties=[1])
Drag options to blanks, or click blank then click option'
Apika.BasicProperties(delivery_mode=2)
Bpika.BasicProperties(delivery_mode=1)
Cpika.BasicProperties(persistent=True)
Dpika.BasicProperties(delivery_mode='2')
Attempts:
3 left
💡 Hint
Common Mistakes
Using delivery_mode=1 which is non-persistent.
Passing delivery_mode as a string instead of integer.
Using persistent=True which is not a valid property.
4fill in blank
hard

Fill both blanks to publish a message with content type 'text/plain' and priority 5.

RabbitMQ
channel.basic_publish(exchange='', routing_key='task_queue', body='Hello', properties=pika.BasicProperties(content_type=[1], priority=[2]))
Drag options to blanks, or click blank then click option'
A'text/plain'
B5
C'application/json'
D10
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong content type like 'application/json'.
Using priority as a string instead of integer.
5fill in blank
hard

Fill all three blanks to publish a message with delivery_mode 2, content_type 'application/json', and priority 8.

RabbitMQ
channel.basic_publish(exchange='', routing_key='task_queue', body='{}', properties=pika.BasicProperties(delivery_mode=[1], content_type=[2], priority=[3]))
Drag options to blanks, or click blank then click option'
A1
B'application/json'
C8
D2
Attempts:
3 left
💡 Hint
Common Mistakes
Using delivery_mode 1 which is non-persistent.
Using wrong content_type string.
Using priority as string instead of integer.