0
0
RabbitMQdevops~10 mins

Event sourcing with 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 declare a durable queue named 'events'.

RabbitMQ
channel.queue_declare(queue='events', durable=[1])
Drag options to blanks, or click blank then click option'
ATrue
BFalse
CNone
D0
Attempts:
3 left
💡 Hint
Common Mistakes
Using False makes the queue non-durable, risking message loss.
2fill in blank
medium

Complete the code to publish a message to the 'events' exchange with routing key 'user.created'.

RabbitMQ
channel.basic_publish(exchange='events', routing_key=[1], body=message)
Drag options to blanks, or click blank then click option'
A'events'
B'user.updated'
C'order.created'
D'user.created'
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong routing keys causes messages to be lost or misrouted.
3fill in blank
hard

Fix the error in the code to consume messages from the 'events' queue with manual acknowledgments.

RabbitMQ
channel.basic_consume(queue='events', on_message_callback=callback, auto_ack=[1])
Drag options to blanks, or click blank then click option'
ATrue
BNone
CFalse
D0
Attempts:
3 left
💡 Hint
Common Mistakes
Using True causes messages to be acknowledged immediately, risking loss.
4fill in blank
hard

Fill both blanks to declare a topic exchange named 'events' and bind the 'user_events' queue to receive all user-related events.

RabbitMQ
channel.exchange_declare(exchange='events', exchange_type=[1])
channel.queue_bind(queue='user_events', exchange='events', routing_key=[2])
Drag options to blanks, or click blank then click option'
A'topic'
B'direct'
C'user.*'
D'#'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'direct' exchange type does not support pattern matching.
5fill in blank
hard

Fill all three blanks to create a dictionary comprehension that stores event data for events with version greater than 1.

RabbitMQ
event_data = {event['id']: event[1] for event in events if event['version'] [2] [3]
Drag options to blanks, or click blank then click option'
A['data']
B>
C1
D['payload']
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong keys or comparison operators causes incorrect filtering or data extraction.