0
0
RabbitMQdevops~10 mins

Why integration patterns connect systems 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 RabbitMQ queue named 'task_queue'.

RabbitMQ
channel.queue_declare(queue=[1])
Drag options to blanks, or click blank then click option'
A'connection'
B'exchange'
C'routing_key'
D'task_queue'
Attempts:
3 left
💡 Hint
Common Mistakes
Using exchange or routing_key instead of 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='', routing_key=[1], body='Hello World!')
Drag options to blanks, or click blank then click option'
A'default'
B'hello'
C'task_queue'
D'message_queue'
Attempts:
3 left
💡 Hint
Common Mistakes
Using exchange name or unrelated strings as routing key.
3fill in blank
hard

Fix the error in the code to consume messages from 'task_queue' with a callback function named 'callback'.

RabbitMQ
channel.basic_consume(queue=[1], on_message_callback=callback, auto_ack=True)
Drag options to blanks, or click blank then click option'
A'task_queue'
B'consume'
C'queue'
D'callback'
Attempts:
3 left
💡 Hint
Common Mistakes
Putting the callback function name instead of the queue name.
4fill in blank
hard

Fill both blanks to declare a durable queue and publish a persistent message to it.

RabbitMQ
channel.queue_declare(queue=[1], durable=[2])
channel.basic_publish(exchange='', routing_key=[1], body='Important task', properties=pika.BasicProperties(delivery_mode=2))
Drag options to blanks, or click blank then click option'
A'task_queue'
BTrue
CFalse
D'temp_queue'
Attempts:
3 left
💡 Hint
Common Mistakes
Using different queue names or setting durable to False.
5fill in blank
hard

Fill all three blanks to create a direct exchange, bind a queue to it with a routing key, and publish a message.

RabbitMQ
channel.exchange_declare(exchange=[1], exchange_type=[2])
channel.queue_bind(queue=[3], exchange=[1], routing_key='info')
channel.basic_publish(exchange=[1], routing_key='info', body='Log message')
Drag options to blanks, or click blank then click option'
A'logs'
B'direct'
C'log_queue'
D'fanout'
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong exchange types or mismatched queue/exchange names.