pub struct RabbitExchange { /* private fields */ }Expand description
Describes the exchange side of a RabbitQueue binding.
Like every descriptor in this crate it only records the EXPECTED topology; nothing is
declared unless the broker was built with
declare_topology(true).
§Examples
use ruststream_lapin::RabbitExchange;
let events = RabbitExchange::topic("events").durable(true);
assert_eq!(events.name(), "events");Implementations§
Source§impl RabbitExchange
impl RabbitExchange
Sourcepub fn direct(name: impl Into<String>) -> Self
pub fn direct(name: impl Into<String>) -> Self
A direct exchange: routes on an exact routing-key match.
Sourcepub fn topic(name: impl Into<String>) -> Self
pub fn topic(name: impl Into<String>) -> Self
A topic exchange: routes on dot-separated routing-key patterns (order.*).
Sourcepub fn fanout(name: impl Into<String>) -> Self
pub fn fanout(name: impl Into<String>) -> Self
A fanout exchange: routes every message to every bound queue.
Sourcepub fn headers(name: impl Into<String>) -> Self
pub fn headers(name: impl Into<String>) -> Self
A headers exchange: routes on header attributes instead of the routing key.
Sourcepub fn custom(name: impl Into<String>, kind: impl Into<String>) -> Self
pub fn custom(name: impl Into<String>, kind: impl Into<String>) -> Self
An exchange of a plugin-provided type, for example "x-delayed-message".
Sourcepub fn consistent_hash(name: impl Into<String>) -> Self
pub fn consistent_hash(name: impl Into<String>) -> Self
A consistent-hash exchange (the x-consistent-hash type from the
rabbitmq_consistent_hash_exchange
plugin): distributes messages across the queues bound to it by hashing the routing key,
so partition-like fan-out is a server-side concern rather than a client one.
Each queue binds with a routing key that is its integer weight ("1", "2", …); the
broker splits the hash space proportionally. Requires the plugin to be enabled on the
broker, so it lives behind the plugin-consistent-hash feature.
§Examples
use ruststream_lapin::{RabbitExchange, RabbitQueue};
let hashed = RabbitExchange::consistent_hash("orders-by-key");
// Bind a queue with its weight as the routing key:
let shard = RabbitQueue::new("shard-a").bind(hashed, "1");Sourcepub fn durable(self, durable: bool) -> Self
pub fn durable(self, durable: bool) -> Self
Whether the exchange survives a broker restart. Defaults to true.
Sourcepub fn auto_delete(self, auto_delete: bool) -> Self
pub fn auto_delete(self, auto_delete: bool) -> Self
Whether the exchange is deleted when its last binding is removed. Defaults to false.
Trait Implementations§
Source§impl Clone for RabbitExchange
impl Clone for RabbitExchange
Source§fn clone(&self) -> RabbitExchange
fn clone(&self) -> RabbitExchange
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more