[−][src]Struct spectacles_brokers::amqp::AmqpBroker
Central AMQP message brokers client.
Fields
group: String
The group used for consuming and producing messages.
subgroup: Option<String>
The subgroup used for consuming and producing messages.
Methods
impl AmqpBroker
[src]
pub fn new(
amqp_uri: String,
group: String,
subgroup: Option<String>
) -> impl Future<Item = AmqpBroker, Error = Error>
[src]
amqp_uri: String,
group: String,
subgroup: Option<String>
) -> impl Future<Item = AmqpBroker, Error = Error>
Creates a new AMQP-based message broker, with the provided address, and groups.
Example
use std::env::var; use spectacles_brokers::amqp::*; use futures::future::future; fn main() { let amqp = var("AMQP_URL").expect("No AMQP Address has been provided."); tokio::run({ AmqpBroker::new(amqp, "mygroup".to_string(), None) .map(|broker| { /// Publish and subscribe to events here. }); }); }
pub fn publish(
&self,
evt: &str,
payload: Vec<u8>,
properties: AmqpProperties
) -> impl Future<Item = Option<u64>, Error = Error>
[src]
&self,
evt: &str,
payload: Vec<u8>,
properties: AmqpProperties
) -> impl Future<Item = Option<u64>, Error = Error>
Publishes a payload for the provided event to the message brokers. You must serialize all payloads to a Vector of bytes. This method accepts an AMQPProperties struct which will set the AMQP properties for this message. See here for more details on the various AMQP properties.
Example
-- snip --
AmqpBroker::new(AMQP_URI, "mygroup".to_string(), None) .and_then(|broker| broker.publish( "MESSAGE_CREATE", b"{'content': 'Hi'}".to_vec(), AmqpProperties::default().with_content_type("application/json") ))
pub fn consume(&self, evt: &str) -> AmqpConsumer
[src]
Attempts to consume the provided event. Returns a stream, which is populated with each incoming AMQP message.
Example
-- snip -- AmqpBroker::new(addr, "mygroup", None) .and_then(|broker| broker.consume("MESSAGE_CREATE")) .for_each(|message| { // Poll the consumer stream. println!("Message Event Received: {}", payload); Ok(()) }) .map_err(|err| { eprintln!("Failed to consume queue. {:?}", err); })
Trait Implementations
impl Clone for AmqpBroker
[src]
fn clone(&self) -> AmqpBroker
[src]
default fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
Auto Trait Implementations
impl Send for AmqpBroker
impl Sync for AmqpBroker
Blanket Implementations
impl<T> From for T
[src]
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
impl<T, U> TryFrom for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,