# 仿RabbitMQ实现消息队列 **Repository Path**: wbpro/message-queue ## Basic Information - **Project Name**: 仿RabbitMQ实现消息队列 - **Description**: 这是一个仿RabbitMQ实现的消息队列组件项目 - **Primary Language**: C++ - **License**: Not specified - **Default Branch**: master - **Homepage**: http://111.230.81.226:8080/login.html - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 1 - **Created**: 2025-04-22 - **Last Updated**: 2025-04-22 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # RabbitMQ-Like Message Queue Component README ## Project Overview This project aims to emulate RabbitMQ, delivering a comprehensive and efficient messaging queue system ideal for message passing and decoupling in distributed systems. It adheres to core AMQP (Advanced Message Queuing Protocol) principles, supporting the producer-consumer model, persistent messaging, a variety of exchange types, message acknowledgment mechanisms, and robust client-server interactions. Implemented in C++, it leverages the Muduo networking library for high-performance, event-driven processing and scalability. ## Key Features - **Queue Management**: Supports creation, deletion, and persistent storage/retrieval of queues. - **Exchange Types**: Implements Direct, Fanout, and Topic exchanges for routing messages based on rules. - **Message Acknowledgments**: Supports both automatic and manual acknowledgment for reliable message handling. - **Persistence & Garbage Collection**: Ensures message durability with efficient garbage collection strategies. - **Client Interfaces**: Offers simplified APIs for producers and consumers to publish and subscribe to messages. - **Virtual Host Concept**: Organizes exchanges, queues, bindings as a logical unit for data management and persistence. - **Routing Matching**: Executes routing logic based on exchange types and binding rules. - **Consumer Management**: Manages consumer subscriptions and message confirmations. - **Channel Management**: Manages the lifecycle of channels for orderly message processing and transmission. - **Connection Management**: Maintains client-server connections with open/close capabilities. ## Technical Stack - **Programming Language**: C++ - **Networking Library**: Muduo - **Persistence Storage**: SQLite - **Message Serialization**: Google Protobuf - **Logging System**: Custom variadic argument-based logging implementation ## Getting Started ### Environment Requirements - **Linux OS**: Ubuntu or CentOS recommended, with kernel version >= 2.6.28 - **Compiler**: GCC >= 4.7 or Clang >= 3.5 - **Dependencies**: Boost (for `boost::any` only) - **Tools**: CMake, Git ### Installation Steps 1. **Installation dependency**: ```bash # Ubuntu sudo apt install g++ cmake make libboost-dev # CentOS sudo yum install gcc-c++ cmake make boost-devel ``` 2. **Get project source code**: ```bash git clone https://gitee.com/zhaobohan/message-queue.git ``` 3. **Install basic tools and libraries**: - To install wget (if not installed by default) : ``` sudo apt-get install wget ``` - Replace the domestic software source, back up the original sources.list file, and add the new software source content. For example, using Alibaba Cloud or Tsinghua University's source: ``` sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak sudo apt-get update ``` - Install lrzsz transfer tool: ``` sudo apt-get install lrzsz ``` - Install compilers gcc and g++ : ``` sudo apt-get install gcc g++ ``` - Install the project build tool make: ``` sudo apt-get install make ``` - Install debugger gdb: ``` sudo apt-get install gdb ``` - Install version control system git: ``` sudo apt-get install git ``` 4. **Installing CMake**: - Installing CMake ``` sudo apt-get install cmake ``` 5. **Installing Protobuf**: - Install Protobuf's dependency libraries: ``` sudo apt-get install autoconf automake libtool curl unzip gzip ``` - Download the Protobuf package and install it: ``` wget https://github.com/protocolbuffers/protobuf/releases/download/v3.20.2/protobuf-all-3.20.2.tar.gz tar -zxf protobuf-all-3.20.2.tar.gz ./autogen.sh ./configure make sudo make install protoc --version ``` 6. **Install Muduo library** : - Download the Muduo library source code via git or use an alternate download link: ``` git clone https://github.com/chenshuo/muduo.git wget https://gitee.com/hansionz/mq/raw/master/resource/muduo-master.zip ``` - Install the dependent environment and run the script to compile the installation: ``` sudo apt-get install libz-dev libboost-all-dev unzip muduo-master.zip ./build.sh ./build.sh install ``` 7. **Install SQLite3**: - Install SQLite3: ``` sudo apt-get install sqlite3 libsqlite3-dev ``` 8. **Install Gtest**: - Install Gtest: ``` sudo apt-get install libgtest-dev ``` ## Documentation & Contributions - **Project Documentation**: Detailed documentation resides in the `README.md` and `docs` directory of the repository. - **Contribution Guidelines**: Engage in discussions or contribute to the project via email at zhaobohan_free@163.com. ## Open Source Licensing This project is licensed under a BSD-style license. Please review the [LICENSE](https://github.com/your-repo-url/blob/master/LICENSE) file before usage. --- This README provides an overview of the RabbitMQ-like message queue component's key features and usage instructions, tailored to guide developers in swiftly understanding and utilizing the project. Adjust actual project URLs and details accordingly.