pub struct ServerTxPublisher { /* private fields */ }Expand description
The live publisher backed by AMQP server transactions (tx.select / tx.commit /
tx.rollback).
Between begin_transaction and
commit messages accumulate on the broker inside the
channel transaction and become visible atomically at commit;
abort rolls them back server-side. Outside a transaction
publish behaves like the fire-and-forget publisher.
Only the borrowed transaction kind (TransactionalPublisher) applies here, unlike
ConfirmsPublisher: tx.select puts the channel itself into transactional mode, so the
transaction is channel state with exactly one instance, and there is no buffer for an owned
Transaction value to own.
Clones share the transactional channel and its open/closed state. Interleaving publish
and begin_transaction/commit from concurrent tasks is not supported: which side of the
transaction boundary a concurrent publish lands on would be a race either way. Like every
live publisher it aliases the connection and may outlive it: after shutdown every operation
reports AmqpError::Closed.
Trait Implementations§
Source§impl Clone for ServerTxPublisher
impl Clone for ServerTxPublisher
Source§fn clone(&self) -> ServerTxPublisher
fn clone(&self) -> ServerTxPublisher
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ServerTxPublisher
impl Debug for ServerTxPublisher
Source§impl Publisher for ServerTxPublisher
impl Publisher for ServerTxPublisher
Source§async fn publish(&self, msg: OutgoingMessage<'_>) -> Result<(), Self::Error>
async fn publish(&self, msg: OutgoingMessage<'_>) -> Result<(), Self::Error>
Publishes msg: into the open server transaction, or plainly when none is open.
§Errors
Returns AmqpError::Closed once the broker has shut down and AmqpError::Publish
when the channel rejects the frame.
§Cancel safety
Not cancel safe: dropping the future may leave the message queued in the transaction or not.
Source§impl TransactionalPublisher for ServerTxPublisher
impl TransactionalPublisher for ServerTxPublisher
Source§async fn begin_transaction(&self) -> Result<(), Self::Error>
async fn begin_transaction(&self) -> Result<(), Self::Error>
Opens a server transaction (tx.select on first use).
§Errors
Returns AmqpError::Transaction when a transaction is already open on this handle
(the open transaction is left untouched), AmqpError::Closed once the broker has shut
down, and AmqpError::Publish when the transactional channel cannot be set up.
Source§async fn commit(&self) -> Result<(), Self::Error>
async fn commit(&self) -> Result<(), Self::Error>
Commits the open server transaction.
§Errors
Returns AmqpError::Transaction when no transaction is open, and
AmqpError::Publish when tx.commit fails; the transaction state on the broker is
then unknown (the channel may be closed) and the publisher should be discarded.
Source§async fn abort(&self) -> Result<(), Self::Error>
async fn abort(&self) -> Result<(), Self::Error>
Rolls back the open server transaction.
§Errors
Returns AmqpError::Transaction when no transaction is open, and
AmqpError::Publish when tx.rollback fails.