Bird
0
0

You have this code snippet:

medium📝 Troubleshoot Q6 of 15
RabbitMQ - Performance Tuning
You have this code snippet:
connection = pika.BlockingConnection()
channel = connection.channel()
channel.close()
channel.basic_publish(exchange='', routing_key='test', body='Hello')
What is the problem here?
ARouting key cannot be empty
BConnection is not closed properly
CPublishing on a closed channel causes an error
DExchange name is missing
Step-by-Step Solution
Solution:
  1. Step 1: Identify channel state before publishing

    The channel is closed before calling basic_publish.
  2. Step 2: Understand effect of publishing on closed channel

    Publishing on a closed channel raises an error because the channel is not active.
  3. Final Answer:

    Publishing on a closed channel causes an error -> Option C
  4. Quick Check:

    Closed channel publish error = D [OK]
Quick Trick: Do not publish after closing channel; open a new one [OK]
Common Mistakes:
MISTAKES
  • Ignoring channel closed state
  • Thinking connection closure is the issue
  • Confusing exchange and routing key requirements

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More RabbitMQ Quizzes