Complete the code to enable publisher confirms on the channel.
channel.[1]()To enable publisher confirms in RabbitMQ, you call confirm_select() on the channel.
Complete the code to publish a message and wait for confirmation.
channel.basic_publish(exchange='', routing_key='task_queue', body='Hello') channel.[1]()
After publishing, wait_for_confirms() waits for the broker to confirm the message.
Fix the error in the code to properly handle publisher confirms.
channel.basic_publish(exchange='', routing_key='jobs', body='Run') if not channel.[1](): print('Message not confirmed!')
The correct method to check for confirms is wait_for_confirms(). It returns True if all messages are confirmed.
Fill both blanks to create a dictionary comprehension that maps message IDs to their confirmation status.
confirms = {msg_id: channel.[1](msg_id) for msg_id in message_ids if channel.[2](msg_id)}The method is_acknowledged checks if a message is confirmed, and is_pending checks if it is still waiting for confirmation.
Fill all three blanks to create a dictionary of message IDs and their statuses filtered by confirmed messages.
confirmed_msgs = {msg_id: status for msg_id, status in statuses.items() if msg_id [1] confirmed_ids and status [2] 'ack' and not status [3] 'nack'}The code filters messages where the ID is in the confirmed list, status equals 'ack', and status is not 'nack'.