Crates.io | spectacles-brokers |
lib.rs | spectacles-brokers |
version | 1.4.0 |
source | src |
created_at | 2019-03-10 03:20:22.493692 |
updated_at | 2019-04-13 21:35:23.873441 |
description | Message brokers which allow for powerful communication between Spectacles services. |
homepage | |
repository | https://github.com/spec-tacles/spectacles-rs |
max_upload_size | |
id | 119698 |
size | 16,370 |
Message brokers which allow for simple communication between Spectacles services.
use std::env::var;
use futures::future::Future;
use spectacles_brokers::amqp::*;
fn main() {
let addr = var("AMQP_ADDR").expect("No AMQP server address found.");
let connect = AmqpBroker::new(addr, "test".to_string(), None);
let result = connect.and_then(|broker| {
let json = r#"{"message": "Example Publish."}"#.as_bytes();
let props = AmqpProperties::default().with_content_type("application/json".to_string();
broker.publish("HELLO", json.to_vec(), props).map_err(|err| {
eprintln!("An error was encountered during publish: {}", err);
})
}).map(|_| {
println!("Message publish succeeded, check the other window!");
})
tokio::run(result);
}
More examples can be found in the [examples
] directory.