| Crates.io | rocketmq-controller |
| lib.rs | rocketmq-controller |
| version | 0.7.0 |
| created_at | 2025-12-07 15:41:06.520374+00 |
| updated_at | 2025-12-07 15:41:06.520374+00 |
| description | RocketMQ Controller Module - High Availability Raft-based Controller |
| homepage | https://github.com/mxsm/rocketmq-rust |
| repository | https://github.com/mxsm/rocketmq-rust |
| max_upload_size | |
| id | 1971819 |
| size | 301,165 |
RocketMQ Controller Module - High Availability Controller based on Raft
RocketMQ Controller is the core management component of RocketMQ cluster, responsible for:
┌──────────────────────────────────────────┐
│ Controller Manager │
├──────────────────────────────────────────┤
│ │
│ ┌────────────┐ ┌────────────────────┐ │
│ │ Raft │ │ Metadata Store │ │
│ │ Controller │ │ │ │
│ │ │ │ - Broker Manager │ │
│ │ - Election │ │ - Topic Manager │ │
│ │ - Replica │ │ - Config Manager │ │
│ └────────────┘ └────────────────────┘ │
│ │
│ ┌────────────────────────────────────┐ │
│ │ Processor Manager │ │
│ │ │ │
│ │ - Register Broker │ │
│ │ - Heartbeat │ │
│ │ - Create/Update Topic │ │
│ │ - Query Metadata │ │
│ └────────────────────────────────────┘ │
└──────────────────────────────────────────┘
use rocketmq_controller::*;
#[tokio::main]
async fn main() -> Result<()> {
// Create configuration
let config = ControllerConfig::new(
1, // node_id
"127.0.0.1:9876".parse().unwrap()
)
.with_raft_peers(vec![
RaftPeer { id: 1, addr: "127.0.0.1:9876".parse().unwrap() },
RaftPeer { id: 2, addr: "127.0.0.1:9877".parse().unwrap() },
RaftPeer { id: 3, addr: "127.0.0.1:9878".parse().unwrap() },
])
.with_storage_path("/data/controller".into());
// Create and start Controller
let manager = ControllerManager::new(config).await?;
manager.start().await?;
// Wait...
// Graceful shutdown
manager.shutdown().await?;
Ok(())
}
Main dependencies:
raft-rs - Raft consensus algorithm implementationtokio - Async runtimedashmap - Concurrent hash mapserde - Serialization/deserializationtracing - Logging and tracingcargo build -p rocketmq-controller
cargo test -p rocketmq-controller
cargo bench -p rocketmq-controller
| Feature | Java (DLedger) | Rust (raft-rs) |
|---|---|---|
| Consensus Algorithm | DLedger | raft-rs |
| Async Model | Netty | Tokio |
| Concurrency Control | ConcurrentHashMap | DashMap |
| Error Handling | Exceptions | Result<T, E> |
| Type Safety | Runtime | Compile-time |
Contributions are welcome! Please see CONTRIBUTING.md.
Licensed under Apache License 2.0 or MIT license, at your option.