Skip to main content

RequestReply

Trait RequestReply 

Source
pub trait RequestReply: Publisher {
    type Reply: IncomingMessage;

    // Required method
    fn request(
        &self,
        msg: OutgoingMessage<'_>,
        timeout: Duration,
    ) -> impl Future<Output = Result<Self::Reply, Self::Error>> + Send;
}
Expand description

A publisher that supports synchronous request / reply messaging.

Naturally implemented by NATS core and NATS JetStream’s req pattern. Brokers without native reply correlation (Kafka, RabbitMQ classic queues) do not implement this; users that need request / reply on those transports must emulate it themselves.

Required Associated Types§

Source

type Reply: IncomingMessage

The reply message type.

Required Methods§

Source

fn request( &self, msg: OutgoingMessage<'_>, timeout: Duration, ) -> impl Future<Output = Result<Self::Reply, Self::Error>> + Send

Publishes msg and awaits a single correlated reply, or fails after timeout.

§Errors

Returns Self::Error when the broker rejects the publish, the reply times out, or the underlying transport fails before a reply arrives.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§