Complete the code to acknowledge a message in RabbitMQ using the channel.
channel.[1](delivery_tag=method.delivery_tag)The basic_ack method tells RabbitMQ that the message was received and processed successfully.
Complete the code to reject a message and requeue it in RabbitMQ.
channel.basic_reject(delivery_tag=method.delivery_tag, requeue=[1])False will discard the message instead of requeuing.None causes a type error.Setting requeue=True tells RabbitMQ to put the message back to the queue for redelivery.
Fix the error in the code to negatively acknowledge multiple messages at once.
channel.basic_nack(delivery_tag=method.delivery_tag, multiple=[1])False only nacks a single message.None causes a type error.Setting multiple=True negatively acknowledges all messages up to the given delivery tag.
Fill both blanks to consume messages with manual acknowledgment enabled.
channel.basic_consume(queue='task_queue', on_message_callback=callback, auto_ack=[1], [2]='task_queue')
auto_ack=True disables manual ack.queue instead of consumer_tag for the second blank.Setting auto_ack=False enables manual acknowledgment. The consumer_tag identifies the consumer.
Fill both blanks to create a dictionary comprehension that filters messages with priority greater than 5 and acknowledges them.
acknowledged = {msg_id:priority for msg_id, priority in messages.items() if priority [1] 5 and channel.basic_ack(delivery_tag=[2])}The dictionary comprehension uses ':' to map keys to values, filters priorities greater than 5, and acknowledges each message by its delivery tag.