pub struct OutgoingMessage {
pub payload: Bytes,
pub key: Option<String>,
pub ordering_key: Option<Bytes>,
pub event_time_ms: Option<u64>,
pub properties: Vec<(String, String)>,
pub deliver_at_ms: Option<i64>,
pub replication_clusters: Vec<String>,
pub txn_id: Option<TxnId>,
}Expand description
Convenience alias for outgoing application messages.
Wraps a Bytes payload plus optional pb::MessageMetadata overrides.
The producer state machine assigns the sequence id and stamps publish
time on send.
Fields§
§payload: BytesApplication payload bytes.
key: Option<String>Optional message key (sets partition_key).
ordering_key: Option<Bytes>Optional ordering key.
event_time_ms: Option<u64>Optional event time (millis since epoch).
properties: Vec<(String, String)>Optional per-message properties.
deliver_at_ms: Option<i64>Optional absolute deliver-at time (millis since epoch). Mirrors Java’s
TypedMessageBuilder#deliverAt; the broker holds the message until the deadline.
replication_clusters: Vec<String>Optional explicit replication cluster list. Mirrors Java’s
TypedMessageBuilder#replicationClusters. An empty vector means “use the namespace
default”; pass vec!["__local__".to_owned()] to opt out of replication entirely
(Java’s disableReplication() writes the same sentinel).
txn_id: Option<TxnId>Optional transaction id (PIP-31). When set, the broker treats this publish as part
of the open transaction. Mirrors Java Producer#newMessage(Transaction).
Implementations§
Source§impl OutgoingMessage
impl OutgoingMessage
Sourcepub fn with_payload(payload: impl Into<Bytes>) -> Self
pub fn with_payload(payload: impl Into<Bytes>) -> Self
Construct an OutgoingMessage from raw payload bytes.
Sourcepub fn ordering_key(self, key: impl Into<Bytes>) -> Self
pub fn ordering_key(self, key: impl Into<Bytes>) -> Self
Set the ordering key.
Sourcepub fn event_time_ms(self, ts: u64) -> Self
pub fn event_time_ms(self, ts: u64) -> Self
Set the event time (milliseconds since epoch).
Sourcepub fn property(self, key: impl Into<String>, value: impl Into<String>) -> Self
pub fn property(self, key: impl Into<String>, value: impl Into<String>) -> Self
Append a property.
Sourcepub fn deliver_at_ms(self, ts_ms: i64) -> Self
pub fn deliver_at_ms(self, ts_ms: i64) -> Self
Mirrors TypedMessageBuilder#deliverAt. The broker holds the message until the
supplied UNIX-epoch millisecond deadline before dispatching it.
Sourcepub fn deliver_after_ms(self, now_ms: i64, delay_ms: i64) -> Self
pub fn deliver_after_ms(self, now_ms: i64, delay_ms: i64) -> Self
Mirrors TypedMessageBuilder#deliverAfter. Stamps the message with
now_ms + delay_ms as the absolute UNIX-epoch millisecond
deadline. The caller supplies now_ms so this stays
sans-io-pure (ADR-0011 invariant #3): the tokio engine convenience
methods snapshot the host clock at the call site; the moonpool
engine plugs in a virtual wall clock so the resulting wire bytes
are deterministic across seeds. Use Self::deliver_at_ms for
the absolute-deadline variant.
Sourcepub fn replication_clusters(self, clusters: Vec<String>) -> Self
pub fn replication_clusters(self, clusters: Vec<String>) -> Self
Mirrors TypedMessageBuilder#replicationClusters. Overrides the namespace-default
replication list with the given clusters for this message only.
Sourcepub fn disable_replication(self) -> Self
pub fn disable_replication(self) -> Self
Mirrors TypedMessageBuilder#disableReplication. Sentinel for “do not replicate this
message to any other cluster” — the broker recognises the __local__ cluster id.
Sourcepub fn txn(self, txn_id: TxnId) -> Self
pub fn txn(self, txn_id: TxnId) -> Self
Mirrors Java Producer#newMessage(Transaction). Stamps the supplied transaction id
on the publish so the broker treats it as part of the open transaction (PIP-31).
Sourcepub fn value(self, payload: impl Into<Bytes>) -> Self
pub fn value(self, payload: impl Into<Bytes>) -> Self
Set the payload bytes. Mirrors Java TypedMessageBuilder#value(byte[]) for the raw
bytes case — schema-encoded values land here after the schema-aware layer serialises
them. Lets the builder be constructed OutgoingMessage::default().key(..).value(..)
without forcing the caller through Self::with_payload.
Sourcepub fn send(self, producer: &Producer) -> SendFut ⓘ
pub fn send(self, producer: &Producer) -> SendFut ⓘ
Send this message through producer and return the in-flight
magnetar_runtime_tokio::SendFut. Mirrors the terminal send() step of Java’s
TypedMessageBuilder: producer.newMessage().key(..).value(..).send(). Equivalent
to producer.send(msg.into()), just chainable.
Trait Implementations§
Source§impl Clone for OutgoingMessage
impl Clone for OutgoingMessage
Source§fn clone(&self) -> OutgoingMessage
fn clone(&self) -> OutgoingMessage
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more