0
0
RabbitMQdevops~30 mins

Binding keys and routing keys in RabbitMQ - Mini Project: Build & Apply

Choose your learning style9 modes available
Binding keys and routing keys
📖 Scenario: You are setting up a messaging system using RabbitMQ. You want to route messages to different queues based on specific topics. This helps different parts of your application receive only the messages they need.
🎯 Goal: Build a simple RabbitMQ setup where you create an exchange, bind queues with binding keys, and send messages with routing keys to see how messages are routed.
📋 What You'll Learn
Create a topic exchange named logs_topic
Create two queues named queue_error and queue_info
Bind queue_error to logs_topic with binding key error.*
Bind queue_info to logs_topic with binding key info.#
Publish messages with routing keys error.system and info.user.login
Observe which queues receive which messages
💡 Why This Matters
🌍 Real World
Routing messages with binding keys and routing keys is common in microservices and event-driven systems to direct messages to the right service.
💼 Career
Understanding RabbitMQ routing helps in roles like DevOps engineer, backend developer, and system architect where message brokers are used for scalable communication.
Progress0 / 4 steps
1
Create the exchange and queues
Create a topic exchange called logs_topic. Then create two queues named queue_error and queue_info.
RabbitMQ
Need a hint?

Use exchange_declare with exchange_type='topic' to create the exchange. Use queue_declare to create each queue.

2
Bind queues with binding keys
Bind the queue queue_error to the exchange logs_topic using the binding key error.*. Bind the queue queue_info to the same exchange using the binding key info.#.
RabbitMQ
Need a hint?

Use queue_bind method to connect each queue to the exchange with the correct binding key.

3
Publish messages with routing keys
Publish a message with routing key error.system and another message with routing key info.user.login to the exchange logs_topic.
RabbitMQ
Need a hint?

Use basic_publish to send messages to the exchange with the specified routing keys.

4
Print which queues receive messages
Consume one message from queue_error and one message from queue_info. Print the messages received from each queue.
RabbitMQ
Need a hint?

Use basic_get to get one message from each queue and print the message body.