tokio-amqp 0.3.1

lapin integration with tokio

Lapin integration with tokio

This crate integrates lapin with tokio by using tokio's executor inside of lapin for its internal operations and for consumer delegates.

use tokio_amqp::*;
use lapin::{Connection, ConnectionProperties, Result};
use std::sync::Arc;
use tokio::runtime::Runtime;

async fn tokio_main(rt: Arc<Runtime>) -> Result<()> {
    let addr = std::env::var("AMQP_ADDR").unwrap_or_else(|_| "amqp://".into());
    let conn = Connection::connect(&addr, ConnectionProperties::default().with_tokio(rt)).await?; // Note the `with_tokio()` here
    let channel = conn.create_channel().await?;

    // Rest of your program

fn main() {
    let rt = Arc::new(Runtime::new().expect("failed to create runtime"));