What is the main purpose of setting the prefetch count in RabbitMQ when using fair dispatch?
Think about how RabbitMQ controls message flow to consumers to balance workload.
Setting prefetch=1 tells RabbitMQ to send only one unacknowledged message at a time to a consumer. This helps distribute messages fairly among consumers by not overwhelming any single one.
Given two consumers connected to the same RabbitMQ queue with prefetch=1, what will be the output behavior when 4 messages are published?
Consumer1: prefetch=1 Consumer2: prefetch=1 Publish 4 messages to queue
Consider how prefetch=1 affects message dispatch to multiple consumers.
With prefetch=1, RabbitMQ sends one message to a consumer and waits for its acknowledgment before sending another. This causes messages to be distributed fairly, alternating between consumers.
Which of the following code snippets correctly sets the prefetch count to 1 in a RabbitMQ consumer using Python's pika library?
Look for the correct method name and parameter for setting prefetch in pika.
The basic_qos method with prefetch_count=1 sets the prefetch count correctly. The basic_consume method does not accept a prefetch parameter.
You set prefetch=1 for two consumers on the same queue, but one consumer receives most messages while the other is idle. What is the most likely cause?
Think about how unacknowledged messages affect message flow.
If a consumer does not acknowledge messages, RabbitMQ will not send it more messages, causing imbalance. Prefetch=1 only limits unacknowledged messages but does not force acknowledgments.
Arrange the following steps in the correct order to implement fair dispatch with prefetch=1 in a RabbitMQ consumer application.
Consider the logical order of setup before starting consumption.
You must first create the connection and channel, then set prefetch count, define the callback, and finally start consuming messages.