0
0
RabbitMQdevops~10 mins

Correlation ID for matching replies in RabbitMQ - Interactive Code Practice

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

Complete the code to set a correlation ID when sending a message.

RabbitMQ
channel.basic_publish(exchange='', routing_key='task_queue', body=message, properties=pika.BasicProperties(correlation_id=[1]))
Drag options to blanks, or click blank then click option'
A'abcde-12345'
B'12345'
C12345
Dcorrelation_id
Attempts:
3 left
💡 Hint
Common Mistakes
Using a number instead of a string for correlation_id
Using an undefined variable instead of a string
2fill in blank
medium

Complete the code to check if the reply message has the expected correlation ID.

RabbitMQ
if method.properties.correlation_id == [1]:
    process_reply(body)
Drag options to blanks, or click blank then click option'
A'reply_id'
Bmethod.correlation_id
Ccorrelation_id
D'abcde-12345'
Attempts:
3 left
💡 Hint
Common Mistakes
Comparing to a variable name instead of the string
Using wrong property name
3fill in blank
hard

Fix the error in the code to correctly set the correlation ID in the reply message properties.

RabbitMQ
channel.basic_publish(exchange='', routing_key=props.reply_to, body=response, properties=pika.BasicProperties([1]=props.correlation_id))
Drag options to blanks, or click blank then click option'
AcorrelationId
Bcorrelation_id
CcorrelationID
Dcorr_id
Attempts:
3 left
💡 Hint
Common Mistakes
Using camelCase instead of snake_case
Using incorrect property names
4fill in blank
hard

Fill both blanks to create a reply queue and consume messages with a callback.

RabbitMQ
result = channel.queue_declare(queue='', exclusive=[1])
channel.basic_consume(queue=result.method.queue, on_message_callback=[2], auto_ack=True)
Drag options to blanks, or click blank then click option'
ATrue
BFalse
Ccallback
Dhandle_reply
Attempts:
3 left
💡 Hint
Common Mistakes
Setting exclusive to False
Using wrong callback function name
5fill in blank
hard

Fill all three blanks to send a message with a correlation ID, set up a reply queue, and start consuming replies.

RabbitMQ
corr_id = [1]
channel.basic_publish(exchange='', routing_key='rpc_queue', body=request, properties=pika.BasicProperties(reply_to=callback_queue, correlation_id=corr_id))
channel.basic_consume(queue=callback_queue, on_message_callback=[2], auto_ack=[3])
Drag options to blanks, or click blank then click option'
A'abcde-12345'
Bhandle_response
CTrue
DFalse
Attempts:
3 left
💡 Hint
Common Mistakes
Using a variable instead of string for corr_id
Setting auto_ack to False without manual ack handling