0
0
RabbitMQdevops~10 mins

Why clustering provides high availability in RabbitMQ - Test Your Understanding

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to create a RabbitMQ cluster node connection.

RabbitMQ
connection = pika.BlockingConnection(pika.ConnectionParameters(host=[1]))
Drag options to blanks, or click blank then click option'
A'localhost'
B'rabbitmq'
C'127.0.0.1'
D'cluster-node-1'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'localhost' instead of the cluster node name.
Using IP address instead of the cluster node name.
2fill in blank
medium

Complete the code to declare a durable queue for high availability.

RabbitMQ
channel.queue_declare(queue='task_queue', durable=[1])
Drag options to blanks, or click blank then click option'
ATrue
BFalse
CNone
D0
Attempts:
3 left
💡 Hint
Common Mistakes
Setting durable to False causes the queue to be deleted on restart.
Using None or 0 instead of a boolean value.
3fill in blank
hard

Fix the error in the code to enable mirrored queues for clustering high availability.

RabbitMQ
args = {'x-ha-policy': [1]
channel.queue_declare(queue='task_queue', durable=True, arguments=args)
Drag options to blanks, or click blank then click option'
A'none'
B'all'
C'mirror'
D'single'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'none' disables mirroring.
Using 'mirror' or 'single' are invalid policies.
4fill in blank
hard

Fill both blanks to set up a RabbitMQ cluster connection with automatic recovery and heartbeat.

RabbitMQ
parameters = pika.ConnectionParameters(host='cluster-node-1', heartbeat=[1], blocked_connection_timeout=[2])
connection = pika.BlockingConnection(parameters)
Drag options to blanks, or click blank then click option'
A600
B300
C100
D30
Attempts:
3 left
💡 Hint
Common Mistakes
Setting heartbeat too high causes delays in detecting failures.
Setting blocked_connection_timeout too low causes premature disconnects.
5fill in blank
hard

Fill all three blanks to implement a retry mechanism for connecting to a RabbitMQ cluster.

RabbitMQ
for attempt in range([1]):
    try:
        connection = pika.BlockingConnection(pika.ConnectionParameters(host='cluster-node-1'))
        break
    except pika.exceptions.AMQPConnectionError:
        time.sleep([2])
else:
    raise Exception('Failed to connect after [3] attempts')
Drag options to blanks, or click blank then click option'
A5
B10
C3
D2
Attempts:
3 left
💡 Hint
Common Mistakes
Using too few retries causes early failure.
Using too long sleep delays recovery.