Skip to main content

AsyncMessagePublisher

Trait AsyncMessagePublisher 

Source
pub trait AsyncMessagePublisher: Send + Sync {
    // Required method
    fn publish(
        &self,
        message: Message,
    ) -> impl Future<Output = Result<(), TransportError>> + Send + '_;

    // Provided method
    fn publish_batch(
        &self,
        messages: Vec<Message>,
    ) -> impl Future<Output = Result<(), TransportError>> + Send + '_ { ... }
}
Expand description

Publishes canonical Messages to a transport.

publish resolves Ok only once the adapter’s durable publish threshold is reached; any failure or unknown outcome is Err. The error’s retryability lets the caller (the outbox dispatcher) decide whether to keep the row retryable.

Required Methods§

Source

fn publish( &self, message: Message, ) -> impl Future<Output = Result<(), TransportError>> + Send + '_

Publish a single message.

Provided Methods§

Source

fn publish_batch( &self, messages: Vec<Message>, ) -> impl Future<Output = Result<(), TransportError>> + Send + '_

Publish a batch of messages.

The default publishes sequentially and stops at the first error, so a partial batch may have been published when this returns Err; the caller settles each outbox row by its own claim, so partial progress is safe. Adapters with native batching (a Kafka producer batch, a single multi-row transaction) should override this.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§