Complete the code to set the prefetch count for a RabbitMQ consumer.
channel.basic_qos(prefetch_count=[1])Setting prefetch_count to 1 ensures the consumer processes one message at a time, which helps in tuning throughput by controlling load.
Complete the code to declare a durable queue in RabbitMQ.
channel.queue_declare(queue='task_queue', durable=[1])
Setting durable=True makes the queue survive RabbitMQ restarts, which is important for reliable throughput.
Fix the error in the code to acknowledge a message after processing.
channel.basic_ack(delivery_tag=[1])The delivery_tag is accessed from the method parameter, so method.delivery_tag is correct for acknowledging messages.
Fill both blanks to create a message consumer with manual acknowledgments and prefetch count set.
channel.basic_qos(prefetch_count=[1]) channel.basic_consume(queue='task_queue', on_message_callback=callback, auto_ack=[2])
Setting prefetch_count=1 limits unacknowledged messages to one, and auto_ack=False requires manual acknowledgment, both improving throughput control.
Fill all three blanks to create a dictionary comprehension that filters messages longer than 5 characters and converts keys to uppercase.
filtered = { [1]: [2] for [3], [2] in messages.items() if len([2]) > 5 }This comprehension creates a new dictionary with keys in uppercase and values filtered by length greater than 5.