pub struct ConfirmsTransaction { /* private fields */ }Expand description
An owned confirm-transaction, opened by
transaction on a ConfirmsPublisher.
A private publish buffer: publish appends to this value rather than
to the publisher, commit flushes the whole buffer on the confirm
channel and awaits every acknowledgement, and abort discards it
without touching the broker. Both settle by consuming self, so a double commit or a publish
after settling is a compile error.
Unlike the handle-level buffer of the borrowed kind, any number of these can be open on one publisher at a time, and the publisher keeps publishing directly while they are.
§Examples
use ruststream::{Broker, OutgoingMessage, OwnedTransactions, Transaction};
use ruststream_lapin::{LapinBroker, LapinPublish};
let connected = LapinBroker::new("amqp://localhost:5672").connect().await?;
let publisher = connected.publisher(LapinPublish::default().confirms());
let mut orders = publisher.transaction().await?;
let mut audit = publisher.transaction().await?; // concurrent with `orders`
orders.publish(OutgoingMessage::new("orders", b"{}".as_slice())).await?;
audit.publish(OutgoingMessage::new("audit", b"{}".as_slice())).await?;
orders.commit().await?;
audit.commit().await?;Trait Implementations§
Source§impl Debug for ConfirmsTransaction
impl Debug for ConfirmsTransaction
Source§impl Drop for ConfirmsTransaction
impl Drop for ConfirmsTransaction
Source§impl Transaction for ConfirmsTransaction
impl Transaction for ConfirmsTransaction
Source§async fn commit(self) -> Result<(), Self::Error>
async fn commit(self) -> Result<(), Self::Error>
Publishes the buffered messages in order and awaits every confirm.
§Errors
Returns AmqpError::Closed once the broker has shut down, and AmqpError::Publish
when a message fails to publish or the broker returns a negative confirm. A failed commit
has still consumed the transaction and its buffer is lost: redelivery of the inputs, not
resubmission of the buffer, is the recovery path. Messages already flushed stay
published - publisher confirms give durability per message, not atomicity across them
(use ServerTxPublish for that).
§Cancel safety
Not cancel safe: dropping the future mid-flush leaves an unknown prefix of the buffer published.