Yet another RabbitMQ client implementation in rust with different design goals.
```rust // open a connection to RabbitMQ server let args = OpenConnectionArguments::new("localhost:5672", "user", "bitnami");
let connection = Connection::open(&args).await.unwrap(); connection .register_callback(DefaultConnectionCallback) .await .unwrap();
// open a channel on the connection let channel = connection.openchannel(None).await.unwrap(); channel .registercallback(DefaultChannelCallback) .await .unwrap();
// declare a queue let (queuename, _, _) = channel .queuedeclare(QueueDeclareArguments::default()) .await .unwrap() .unwrap();
// bind the queue to exchange let exchangename = "amq.topic"; channel .queuebind(QueueBindArguments::new( &queuename, exchangename, "eiffel.#", )) .await .unwrap();
////////////////////////////////////////////////////////////////////////////// // start consumer with given name channel .basicconsume(DefaultConsumer::new(args.noack), BasicConsumeArguments::new(&queuename, "examplebasicpubsub")) .await .unwrap();
////////////////////////////////////////////////////////////////////////////// // publish a message let content = String::from( r#" { "meta": {"id": "f9d42464-fceb-4282-be95-0cd98f4741b0", "type": "PublishTester", "version": "4.0.0", "time": 1640035100149}, "data": { "customData": []}, "links": [{"type": "BASE", "target": "fa321ff0-faa6-474e-aa1d-45edf8c99896"}] } "#).into_bytes();
channel .basicpublish(BasicProperties::default(), content, BasicPublishArguments::new(exchangename, "eiffel.a.b.c.d")) .await .unwrap();
// keep the channel
and connection
object from dropping
// NOTE: channel/connection will be closed when drop
time::sleep(time::Duration::from_secs(10)).await;
```