Перейти к основному содержимому
Эта страница ещё не переведена

Ниже показан английский оригинал.

Replies

A reply is the reply of the receive operation it answers: the document names its channel and its message.

A request-reply registration's receive operation carries a reply object. It points at the reply's channel and at the reply type's message component. The reply gets no send operation of its own. Its channel is the destination the reply resolves to: the reply type's #[outgoing(name = "..")], or the name the mount site gives (see Replies). A reply that a naming transform addresses per delivery has no fixed address, and its channel's address is null. The reply's address then says where a client reads it, as a runtime expression such as $message.header#/reply-to. The broker states that expression through PublishPolicy::reply_address_location, and a broker that cannot state it leaves the address out. The example runs with cargo test --example asyncapi_reports --features macros,memory,asyncapi.

Example​

/// The confirmation an order request gets back.
#[derive(Debug, Serialize, Outgoing, JsonSchema)]
struct Confirmed {
id: u64,
}

/// Confirms every order request.
#[subscriber("order-requests", reply("confirmations"))]
async fn confirm(order: &Order) -> Confirmed {
Confirmed { id: order.id }
}