Lapin wrapper that encapsulates the use of connections/channels and provides some helpful methods making it easier to use and less error prone.
```rust use amqpmanager::prelude::*; use futures::FutureExt; use tokioamqp::LapinTokioExt; use serde::{Deserialize, Serialize};
struct SimpleDelivery(String);
async fn main() { let poolmanager = RMQConnectionManager::new("amqp://guest:guest@127.0.0.1:5672//".tostring(), ConnectionProperties::default().withtokio()); let pool = mobc::Pool::builder().build(poolmanager); let amqpmanager = AmqpManager::new(pool).expect("Should create AmqpManager instance"); let amqpsession = amqpmanager.getsession().await.expect("Should create AmqpSession instance"); let queuename = "queue-name"; let createqueueop = CreateQueue { queuename: queuename.tostring(), options: QueueDeclareOptions { autodelete: false, ..Default::default() }, ..Default::default() }; amqpsession.createqueue(createqueueop.clone()).await.expect("createqueue"); amqpsession .publishtoroutingkey(PublishToRoutingKey { routingkey: queuename.tostring(), payload: Payload::new(&SimpleDelivery("Hello World".tostring())).unwrap(), ..Default::default() }) .await .expect("publishtoqueue"); amqpsession .createconsumerwithdelegate( CreateConsumer { queuename: queuename.tostring(), consumername: "consumer-name".tostring(), ..Default::default() }, |delivery: DeliveryResult| async { if let Ok(Some((channel, delivery))) = delivery { channel .basicack(delivery.deliverytag, BasicAckOptions::default()) .map(|| ()) .await; } }, ) .await .expect("createconsumer"); let queue = amqpsession.createqueue(createqueueop.clone()).await.expect("createqueue"); asserteq!(queue.messagecount(), 0, "Messages has been consumed"); } ```
The crate is tested on ubuntu-latest
against the following rust versions: nightly, beta, stable and 1.45.0.
It is possible that it works with older versions as well but this is not tested.
Please see the details of the lapin crate about its requirements.