0
0
RabbitMQdevops~10 mins

Channel and connection pooling 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 create a new connection to RabbitMQ.

RabbitMQ
connection = pika.BlockingConnection(pika.ConnectionParameters('[1]'))
Drag options to blanks, or click blank then click option'
Aopen
Blocalhost
Cchannel
Dqueue
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'channel' or 'queue' instead of the hostname.
Using 'open' which is not a hostname.
2fill in blank
medium

Complete the code to open a new channel from the connection.

RabbitMQ
channel = connection.[1]()
Drag options to blanks, or click blank then click option'
Aopen
Bconnect
Copen_channel
Dchannel
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'connect' which is for connections, not channels.
Using 'open_channel' which is not a valid method.
3fill in blank
hard

Fix the error in the code to properly close the channel.

RabbitMQ
channel.[1]()
Drag options to blanks, or click blank then click option'
Aclose_channel
Bshutdown
Cclose
Ddisconnect
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'close_channel' which is not a method.
Using 'shutdown' or 'disconnect' which are invalid here.
4fill in blank
hard

Fill both blanks to create a dictionary comprehension that maps channel IDs to their status if the channel is open.

RabbitMQ
{ch_id: ch.status for ch_id, ch in channels.items() if ch.[1] == [2]
Drag options to blanks, or click blank then click option'
Astatus
Bopen
Ctrue
Dis_open
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'status' attribute which may not exist.
Comparing to 'closed' instead of 'open'.
Comparing 'is_open' to string 'open' instead of boolean True.
5fill in blank
hard

Fill all three blanks to create a dictionary comprehension that maps connection names to their channels if the channel is open.

RabbitMQ
{conn_name: ch for conn_name, ch in connections.items() if ch.[1] and ch.[2] == [3]
Drag options to blanks, or click blank then click option'
Ais_open
Bstatus
Copen
Dis_closed
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'is_closed' which is the opposite.
Not checking both conditions.