Complete the code to declare a durable queue named 'events'.
channel.queue_declare(queue='events', durable=[1])
Setting durable=True ensures the queue survives RabbitMQ restarts, which is important for event sourcing.
Complete the code to publish a message to the 'events' exchange with routing key 'user.created'.
channel.basic_publish(exchange='events', routing_key=[1], body=message)
The routing key 'user.created' directs the message to queues bound with this key, matching the event type.
Fix the error in the code to consume messages from the 'events' queue with manual acknowledgments.
channel.basic_consume(queue='events', on_message_callback=callback, auto_ack=[1])
Setting auto_ack=False means the consumer must manually acknowledge messages, which is safer for event sourcing.
Fill both blanks to declare a topic exchange named 'events' and bind the 'user_events' queue to receive all user-related events.
channel.exchange_declare(exchange='events', exchange_type=[1]) channel.queue_bind(queue='user_events', exchange='events', routing_key=[2])
A topic exchange allows routing keys with patterns like 'user.*' to match all user events.
Fill all three blanks to create a dictionary comprehension that stores event data for events with version greater than 1.
event_data = {event['id']: event[1] for event in events if event['version'] [2] [3]This comprehension collects the 'payload' of events where the version is greater than 1, using the event ID as key.