extern crate amqpr_api; extern crate tokio_core; extern crate futures; extern crate bytes; extern crate log; extern crate log4rs; use tokio_core::reactor::Core; use tokio_core::net::TcpStream; use futures::Future; use amqpr_api::{start_handshake, open_channel, declare_queue}; use amqpr_api::queue::declare::DeclareQueueOption; use amqpr_api::handshake::SimpleHandshaker; use amqpr_api::errors::*; const LOCAL_CHANNEL_ID: u16 = 42; fn main() { logger(); let mut core = Core::new().unwrap(); let handshaker = SimpleHandshaker { user: "guest".into(), pass: "guest".into(), virtual_host: "/".into(), }; let future = TcpStream::connect(&"127.0.0.1:5672".parse().unwrap(), &core.handle()) .map_err(|e| Error::from(e)) .and_then(|socket| start_handshake(handshaker, socket)) .and_then(|socket| open_channel(socket, LOCAL_CHANNEL_ID)) .and_then(|socket| { let option = DeclareQueueOption { name: "declare_queue_test".into(), is_passive: false, is_durable: false, is_exclusive: false, is_auto_delete: true, is_no_wait: false, }; declare_queue(socket, LOCAL_CHANNEL_ID, option) }); core.run(future).unwrap(); } fn logger() { use log::LogLevelFilter; use log4rs::append::console::ConsoleAppender; use log4rs::config::{Appender, Config, Root}; let stdout = ConsoleAppender::builder().build(); let config = Config::builder() .appender(Appender::builder().build("stdout", Box::new(stdout))) .build(Root::builder().appender("stdout").build( LogLevelFilter::Info, )) .unwrap(); let _handle = log4rs::init_config(config).unwrap(); }