Ниже показан английский оригинал.
Connection
The URI carries the credentials, the virtual host and the scheme; connection_name labels the service in the management UI.
The URI has the form amqp://user:password@host:port/vhost.
A URI without credentials logs in as guest, and RabbitMQ admits guest only from localhost.
A URI without a virtual host connects to the default one, /.
The amqps scheme opens the connection over TLS.
A URI that does not parse fails startup with AmqpError::Connect, in a test as on a server.
connection_name is the name the management UI lists for the connection.
A connection without one is listed by its client address and port.
One connection carries the whole service. Each subscription opens a channel of its own on it. Fire-and-forget publishes share one channel. A confirms or server-transaction publisher opens its own channel on first use, because both modes are channel state.
Example
The service logs in as orders on the virtual host shop.
- Macros
- Manual
/// The user `orders` on the virtual host `shop`; the management UI lists the connection as
/// `orders-svc`.
fn broker() -> LapinBroker {
LapinBroker::new("amqp://orders:secret@localhost:5672/shop").connection_name("orders-svc")
}
#[ruststream::app]
fn app() -> impl App {
RustStream::new(AppInfo::new("orders", "0.1.0")).with_broker(broker(), |b| {
b.include(place);
})
}
/// The user `orders` on the virtual host `shop`; the management UI lists the connection as
/// `orders-svc`.
fn broker() -> LapinBroker {
LapinBroker::new("amqp://orders:secret@localhost:5672/shop").connection_name("orders-svc")
}
fn app() -> impl App {
RustStream::new(AppInfo::new("orders", "0.1.0")).with_broker(broker(), |b| {
b.include(subscriber("orders", Place).build());
})
}