Skip to main content

topic

AmqpAddress::topic asks for the topic terminus: every subscription on the address gets its own copy of each message.

The descriptor attaches its receiver with the terminus capability topic on the link's source. ActiveMQ Artemis and the other brokers that read the capability treat the address as multicast. That is a broadcast: an audit trail and a notifier read the same events, each at its own pace. A deferred retry publishes its copy to the address, so every topic subscription on it receives the copy, not only the one that asked. In process, TestApp copies each message to every topic subscription of the address.

Example​

Two subscriptions of one service on the address orders.placed.

/// Audit keeps a record of every placed order.
#[subscriber(AmqpAddress::topic("orders.placed"))]
async fn audit(event: &OrderPlaced) -> HandlerOutcome {
tracing::info!(event.id, "order recorded");
HandlerOutcome::ack()
}

/// Notifications tell the customer about the same orders, from a copy of their own.
#[subscriber(AmqpAddress::topic("orders.placed"))]
async fn notify(event: &OrderPlaced) -> HandlerOutcome {
tracing::info!(event.id, "customer notified");
HandlerOutcome::ack()
}

#[ruststream::app]
fn app() -> impl App {
let broker = AmqpBroker::new("amqp://artemis:artemis@localhost:5672");
RustStream::new(AppInfo::new("orders", "0.1.0")).with_broker(broker, |b| {
b.include(audit);
b.include(notify);
})
}