|
||
---|---|---|
.. | ||
examples | ||
src | ||
Cargo.toml | ||
README.md |
README.md
RabbitMQ CLI - Rust Implementation
A standalone Rust implementation of the RabbitMQ CLI that connects directly to RabbitMQ nodes using Erlang distribution protocol.
Features
- Direct Connection: Connects to RabbitMQ nodes via Erlang distribution (no server-side changes needed)
- Command Compatibility: Executes the same commands as the Erlang-based CLI
- Pluggable Transport: Supports multiple connection methods (Erlang distribution, future WebSocket support)
- Rich CLI Experience: Better argument parsing, formatting, and interactive features
- Cross-Platform: Works on Linux, macOS, and Windows
Architecture
This CLI replicates the behavior of rabbit_cli_frontend.erl
but implemented in Rust:
- Frontend (Rust): Argument parsing, connection management, output formatting
- Transport Layer: Erlang distribution protocol using
erl_dist
crate - Backend (Erlang): Existing RabbitMQ command handlers (unchanged)
┌─────────────────┐ erl_dist ┌─────────────────┐
│ Rust CLI │ ──────────────► │ RabbitMQ Node │
│ Frontend │ │ (Erlang) │
└─────────────────┘ └─────────────────┘
Installation
From Source
cd rabbitmq-cli-rust
cargo build --release
sudo cp target/release/rabbitmq /usr/local/bin/
Prerequisites
- Erlang Cookie: The CLI needs access to the Erlang cookie for authentication
- Set
RABBITMQ_ERLANG_COOKIE
environment variable, or - Ensure
~/.erlang.cookie
is readable
- Set
Usage
Basic Commands
# List exchanges
rabbitmq list exchanges
# List queues
rabbitmq list queues
# List bindings with filters
rabbitmq list bindings --source my-exchange
rabbitmq list bindings --destination my-queue
# Connect to specific node
rabbitmq --node rabbit@other-host list exchanges
# Verbose output
rabbitmq -vv list exchanges
Global Options
--node, -n
: Specify RabbitMQ node to connect to--verbose, -v
: Increase verbosity (can be used multiple times)--help, -h
: Show help--version, -V
: Show version
Command Discovery
The CLI automatically discovers available commands from the connected RabbitMQ node, so it supports all commands implemented on the server side without needing updates.
Configuration
Erlang Cookie
The CLI needs the Erlang cookie for authentication. It looks for the cookie in:
RABBITMQ_ERLANG_COOKIE
environment variable~/.erlang.cookie
file- System-wide locations (
/var/lib/rabbitmq/.erlang.cookie
, etc.)
Connection
By default, the CLI tries to connect to rabbit@<hostname>
. Override with:
rabbitmq --node rabbit@my-rabbitmq-server list exchanges
Development
Building
cargo build
Testing
# Unit tests
cargo test
# Integration tests (requires running RabbitMQ)
SKIP_INTEGRATION_TESTS= cargo test
Adding Transport Support
The transport layer is pluggable. To add WebSocket support:
- Enable the
websocket
feature - Implement
WebSocketTransport
similar toErlangTransport
- Update connection logic in
cli.rs
Logging
Set RUST_LOG
environment variable for debug output:
RUST_LOG=debug rabbitmq list exchanges
Comparison with Erlang CLI
Feature | Erlang CLI | Rust CLI |
---|---|---|
Connection | Erlang distribution | Erlang distribution + future WebSocket |
Commands | Built-in | Discovered from server |
Performance | Good | Better (less overhead) |
Memory Usage | Higher | Lower |
Startup Time | Slower | Faster |
Interactive Features | Basic | Enhanced (future) |
Cross-Platform | Good | Better |
Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests
- Submit a pull request
License
Same as RabbitMQ (Mozilla Public License 2.0)