amqprs
Yet another RabbitMQ client implementation in rust with different design goals.
Design philosophy
- API first: easy to use, easy to understand. Keep the API similar as python client library so that it is easier for users to move from there.
- Minimum external dependencies: as less exteranl crates as possible
- lock free: no mutex/lock in client library itself
Design Architecture
Example: Consume and Publish
// open a connection to RabbitMQ server
let args = new;
let connection = open.await.unwrap;
connection
.register_callback
.await
.unwrap;
// open a channel on the connection
let channel = connection.open_channel.await.unwrap;
channel
.register_callback
.await
.unwrap;
// declare a queue
let = channel
.queue_declare
.await
.unwrap
.unwrap;
// bind the queue to exchange
let exchange_name = "amq.topic";
channel
.queue_bind
.await
.unwrap;
//////////////////////////////////////////////////////////////////////////////
// start consumer with given name
channel
.basic_consume
.await
.unwrap;
//////////////////////////////////////////////////////////////////////////////
// publish a message
let content = Stringfrom.into_bytes;
channel
.basic_publish
.await
.unwrap;
// keep the `channel` and `connection` object from dropping
// NOTE: channel/connection will be closed when drop
sleep.await;