Bird
0
0

Given the following RabbitMQ cluster setup code snippet, what will be the output if node1 fails?

medium📝 Predict Output Q13 of 15
RabbitMQ - Clustering
Given the following RabbitMQ cluster setup code snippet, what will be the output if node1 fails?
cluster_nodes = ["rabbit@node1", "rabbit@node2", "rabbit@node3"]
message_published = True
if 'rabbit@node1' not in cluster_nodes:
    message_published = False
print(message_published)
ANone
BFalse
CError
DTrue
Step-by-Step Solution
Solution:
  1. Step 1: Analyze cluster_nodes list

    The list still contains 'rabbit@node1' even if node1 fails; the list is static here.
  2. Step 2: Check condition and output

    The condition checks if 'rabbit@node1' is not in the list, which is false, so message_published stays True and prints True.
  3. Final Answer:

    True -> Option D
  4. Quick Check:

    Node1 in list = True output [OK]
Quick Trick: Static list means node failure not reflected here [OK]
Common Mistakes:
MISTAKES
  • Assuming node failure removes it from list automatically
  • Confusing condition logic
  • Expecting runtime error

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More RabbitMQ Quizzes