pub struct Subscriber<T, D>where
D: Decoder<Result = T>,{ /* private fields */ }Expand description
Implementations§
Source§impl<T, D> Subscriber<T, D>where
D: Decoder<Result = T>,
impl<T, D> Subscriber<T, D>where
D: Decoder<Result = T>,
Source§impl<T, D> Subscriber<T, D>where
D: Decoder<Result = T>,
impl<T, D> Subscriber<T, D>where
D: Decoder<Result = T>,
Sourcepub fn name(&self) -> &str
pub fn name(&self) -> &str
Reports the name of this Subscriber.
Source§impl Subscriber<(), NoopDecoder>
impl Subscriber<(), NoopDecoder>
Sourcepub fn new_undecoded(gateway: Gateway, ingress: Ingress) -> Self
pub fn new_undecoded(gateway: Gateway, ingress: Ingress) -> Self
A shorthand for calling new with a NoopDecoder.
Sourcepub fn start_undecoded(handle: &Handle, ingress: Ingress) -> Self
pub fn start_undecoded(handle: &Handle, ingress: Ingress) -> Self
A shorthand for calling start with a
NoopDecoder.
Source§impl<T, D> Subscriber<T, D>where
D: Decoder<Result = T>,
impl<T, D> Subscriber<T, D>where
D: Decoder<Result = T>,
Sourcepub async fn try_declare(&self) -> Result<(), DeclarationError>
pub async fn try_declare(&self) -> Result<(), DeclarationError>
Waits for the connection to RabbitMQ to become available, then issues
the declarations necessary for consuming messages with the Ingress
configured on this subscriber. The declarations include declaring an
exchange (if not a built-in exchange), declaring a queue, and binding
the queue to the exchange in some way. Such declarations are repeatable
(assuming the configuration options don’t change), so it shouldn’t hurt
to call this method any number of times.
If and when this method returns Ok, it can be reasonably expected
that the following calls to receive or
receive_many will be able to eventually
deliver incoming messages, assuming the connectivity to RabbitMQ
remains.
If any of the declarations fail (e.g., a queue by that name already
exists with different configuration), this method returns a
DeclarationError.
Sourcepub async fn declare(&self)
pub async fn declare(&self)
Repeatedly calls try_declare until it
succeeds, with an exponential backoff.
Most declaration errors can only be fixed outside the application, by changing the broker configuration (e.g., deleting a conflicting queue). In such cases, this method may be used, to keep the subscriber spinning (and alerting about the declaration failure) until the issue is fixed externally, at which point the declarations will eventually succeed, and this method will return.
Sourcepub async fn receive(&self) -> Envelope<T>
pub async fn receive(&self) -> Envelope<T>
Receives a single, decode-able message from the broker. Will wait as long as it takes for the first decode-able message to arrive.
Sourcepub async fn receive_many(&self) -> NonEmpty<Envelope<T>>
pub async fn receive_many(&self) -> NonEmpty<Envelope<T>>
Receives a batch of up to batch_size of
decode-able messages from the broker. Will wait as long as it takes for
the first decode-able message to arrive, after which will take no longer
than [BATCH_TIMEOUT] to complete the batch before returning. The final
batch will thus always contain at least one message.