Crates.io | amqp |
lib.rs | amqp |
version | 0.1.3 |
source | src |
created_at | 2014-11-20 22:06:48.822373 |
updated_at | 2019-01-24 15:01:23.879449 |
description | AMQP/RabbitMQ protocol client |
homepage | |
repository | https://github.com/Antti/rust-amqp |
max_upload_size | |
id | 166 |
size | 78,333 |
AMQ protocol implementation in pure rust.
Note: The project is still in very early stages of development, it implements all the protocol parsing, but not all the protocol methods are wrapped/easy to use. Expect the API to be changed in the future.
Have a look at the examples in examples/
folder.
extern crate amqp;
use amqp::Session;
let mut session = Session::open_url("amqp://localhost//").unwrap();
let mut channel = session.open_channel(1).unwrap();
Note: This library supports TLS connections, via OpenSSL. However, this is an optional feature that is enabled by default but can be disabled at build-time (via
cargo --no-default-features
on the command-line, or withdefault-features = false
in yourCargo.toml
).
//The arguments come in following order:
//queue: &str, passive: bool, durable: bool, exclusive: bool, auto_delete: bool, nowait: bool, arguments: Table
let queue_declare = channel.queue_declare("my_queue_name", false, true, false, false, false, Table::new());
channel.basic_publish("", "my_queue_name", true, false,
protocol::basic::BasicProperties{ content_type: Some("text".to_string()), ..Default::default()}, (b"Hello from rust!").to_vec());
This will send message: "Hello from rust!" to the queue named "my_queue_name".
The messages have type of Vec<u8>
, so if you want to send string, first you must convert it to Vec<u8>
.
unwrap
, not handling error responses properly.There's no facility to re-establish connection
No heartbeats support
Not all the amqp methods are implemented in a rust interface. You can still call them manually.
The methods encoding/decoding code is generated using codegen.rb & amqp-rabbitmq-0.9.1.json spec.
You need to have rustfmt installed to generate protocol.rs To generate a new spec, run:
make
To build the project and run the testsuite, use cargo:
cargo build
cargo test
Moreover, there are several source examples to show library usage, and an interactive one to quickly test the library. They can be run directly from cargo:
cargo run --example interactive
On MacOS X If you have problems with OpenSSL during complication, regarding missing headers or linkage, try:
brew install openssl
export OPENSSL_INCLUDE_DIR=`brew --prefix openssl`/include
export OPENSSL_LIB_DIR=`brew --prefix openssl`/lib
cargo clean
cargo test
Licensed under either of
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.