Complete the code to open a new connection to RabbitMQ server.
connection = pika.BlockingConnection(pika.ConnectionParameters('[1]'))
The connection to RabbitMQ is established by specifying the server address, usually 'localhost' for local server.
Complete the code to create a new channel from the connection.
channel = connection.[1]()To create a channel, call the 'channel()' method on the connection object.
Fix the error in the code to properly close the connection.
connection.[1]()The correct method to close a connection is 'close()'.
Fill both blanks to declare a queue and publish a message to it.
channel.queue_declare(queue='[1]') channel.basic_publish(exchange='', routing_key='[2]', body='Hello World!')
The queue name must be the same in both declaration and publishing to send the message correctly.
Fill all three blanks to open a connection, create a channel, and close the connection.
connection = pika.BlockingConnection(pika.ConnectionParameters('[1]')) channel = connection.[2]() connection.[3]()
First, connect to 'localhost', then create a channel with 'channel()', and finally close the connection with 'close()'.