raw
AmqpAddress::raw sends the address as written with no capability, for a deployment's own convention such as /queues/orders on RabbitMQ.
RabbitMQ 4.x addresses a queue by its v2 path, /queues/<name>, and ActiveMQ Artemis accepts a fully qualified queue name.
A bare name in #[subscriber("orders")] is a raw address too.
With no capability on the link, the broker's own configuration decides whether the subscriptions on the address compete or each get a copy.
The address is matched exactly: orders and /queues/orders are two different nodes.
In process, TestApp delivers each message of a raw address once, as on a queue, because there is no broker configuration to consult.
A service whose subscriptions must each get a copy says topic, which is also what the brokers that need the capability have to be told.
Example
- Macros
- Manual
/// `RabbitMQ` 4.x addresses a queue by its v2 path; the string reaches the broker as written.
#[subscriber(AmqpAddress::raw("/queues/orders"))]
async fn fulfil(order: &Order) -> HandlerOutcome {
tracing::info!(order.id, "order fulfilled");
HandlerOutcome::ack()
}
#[ruststream::app]
fn app() -> impl App {
let broker = AmqpBroker::new("amqp://guest:guest@localhost:5672");
RustStream::new(AppInfo::new("fulfillment", "0.1.0")).with_broker(broker, |b| {
b.include(fulfil);
})
}
/// `RabbitMQ` 4.x addresses a queue by its v2 path; the string reaches the broker as written.
struct Fulfil;
impl Handle<Order> for Fulfil {
fn handle(
&self,
order: &Order,
_outs: &(),
_ctx: &mut Context<'_>,
) -> impl Future<Output = Result<(), HandlerOutcome>> {
tracing::info!(order.id, "order fulfilled");
ready(Ok(()))
}
}
fn app() -> impl App {
let broker = AmqpBroker::new("amqp://guest:guest@localhost:5672");
RustStream::new(AppInfo::new("fulfillment", "0.1.0")).with_broker(broker, |b| {
b.include(subscriber(AmqpAddress::raw("/queues/orders"), Fulfil).build());
})
}