Bird
0
0

Identify the issue in this RabbitMQ consumer code snippet that sets prefetch_count=0 and explain why it might cause problems:

medium📝 Troubleshoot Q14 of 15
RabbitMQ - Performance Tuning

Identify the issue in this RabbitMQ consumer code snippet that sets prefetch_count=0 and explain why it might cause problems:

channel.basic_qos(prefetch_count=0)
for method_frame, properties, body in channel.consume('queue'):
    process(body)
    channel.basic_ack(method_frame.delivery_tag)
Aprefetch_count=0 disables prefetch, causing unlimited unacknowledged messages
Bprefetch_count=0 means no messages will be delivered
Cprefetch_count=0 causes syntax error
Dprefetch_count=0 limits to 1 message only
Step-by-Step Solution
Solution:
  1. Step 1: Understand prefetch_count=0 meaning

    Setting prefetch_count=0 disables the limit, allowing unlimited unacknowledged messages.
  2. Step 2: Explain potential problem

    This can overload the consumer with too many messages, causing memory or processing issues.
  3. Final Answer:

    prefetch_count=0 disables prefetch, causing unlimited unacknowledged messages -> Option A
  4. Quick Check:

    prefetch_count=0 means no limit, risk overload = A [OK]
Quick Trick: prefetch_count=0 means unlimited messages, risky for consumers [OK]
Common Mistakes:
MISTAKES
  • Thinking 0 means no messages delivered
  • Assuming it causes syntax error
  • Believing it limits to 1 message

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More RabbitMQ Quizzes