Skip to content

rezamobaraki/rabbitmq-python

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RabbitMQ Python Examples

RabbitMQ Python

A comprehensive collection of RabbitMQ examples and tutorials implemented in Python. This repository demonstrates various messaging patterns and use cases with RabbitMQ message broker.

Created by Reza Mobaraki

Table of contents

General info

This repository contains practical examples of RabbitMQ implementation using Python and the Pika library. Each numbered directory demonstrates different messaging patterns:

  • Directory 1: Basic message sending and receiving
  • Directory 2: Work queues and task distribution
  • Directory 3: Publish/Subscribe pattern
  • Directory 4: Routing with direct exchange
  • Directory 5: Topic exchanges and pattern matching
  • Directory 6: RPC (Remote Procedure Call) pattern
  • new Sample MQ: Advanced consumer/producer examples with utilities

These examples progress from simple point-to-point messaging to complex routing and RPC patterns, making it easy to learn RabbitMQ concepts step by step.

Technologies

This project is built with:

  • Python: 3.9+
  • pika: 1.2.0 (Python client for RabbitMQ)
  • pika-stubs: 0.1.3 (Type hints for pika)
  • RabbitMQ: Message broker (requires separate installation)

Help

If you find any issues or want to contribute improvements:

  1. Report Issues: Open an issue on GitHub with detailed description
  2. Contribute: Fork the repository, make your changes, and submit a pull request
  3. Suggest Improvements: Add modern technologies or messaging patterns

All contributors will be acknowledged in the credits section.

Learning Resources

Prerequisites

Before running these examples, you need to have RabbitMQ server installed and running:

Install RabbitMQ

  • Ubuntu/Debian: sudo apt-get install rabbitmq-server
  • macOS: brew install rabbitmq
  • Windows: Download from RabbitMQ official website
  • Docker: docker run -d --hostname rabbitmq --name rabbitmq -p 5672:5672 -p 15672:15672 rabbitmq:3-management

Start RabbitMQ service

sudo systemctl start rabbitmq-server
# or
sudo service rabbitmq-start

Setup

  • Step 1: Create virtual environment
python -m venv venv
# or
virtualenv -p python3 venv 
  • Step 2: Activate virtual environment
# Linux/macOS
source venv/bin/activate  

# Windows
venv\Scripts\activate
  • Step 3: Install dependencies
pip install -r requirements.txt
  • Step 4: Run examples

Navigate to any numbered directory and run the examples:

# Terminal 1 - Start receiver/consumer
cd 1
python receiver.py

# Terminal 2 - Send messages
cd 1  
python sender.py

Usage Examples

Each directory contains specific messaging patterns:

1. Hello World (Basic messaging)

cd 1
python receiver.py  # In terminal 1
python sender.py    # In terminal 2

2. Work Queues

cd 2
python receiver.py  # Workers (can run multiple)
python sender.py    # Task producer

6. RPC Pattern

cd 6
python server.py    # RPC server
python client.py    # RPC client

Credits

Contributors

License

Distributed under the MIT License. See license for more information.

About

this simple rabbitMQ implemented on python

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages