Skip to main content

IncomingMessage

Struct IncomingMessage 

Source
pub struct IncomingMessage {
    pub id: MessageId,
    pub metadata: Arc<MessageMetadata>,
    pub payload: Bytes,
    pub redelivery_count: u32,
    pub broker_entry_metadata: Option<Arc<BrokerEntryMetadata>>,
}
Expand description

Convenience alias for an incoming message handed back to the caller.

Fields§

§id: MessageId

Message id assigned by the broker.

§metadata: Arc<MessageMetadata>

Pulsar MessageMetadata for the message. Refcounted (Arc) so the batched-delivery path inside the consumer state machine can share one parsed metadata across every sub-message of a batch instead of deep-cloning per message. Field access works transparently (Arc derefs).

§payload: Bytes

Application payload bytes (post-decompression / post-decryption).

§redelivery_count: u32

Broker-supplied redelivery count.

§broker_entry_metadata: Option<Arc<BrokerEntryMetadata>>

PIP-90 BrokerEntryMetadata. None when the broker did not stamp one (older brokers / disabled namespace policy). Carries the broker’s wall-clock timestamp and per-topic index — useful for routing, dedup, and exactly-once-ish flows.

Implementations§

Source§

impl IncomingMessage

Source

pub fn key(&self) -> Option<&str>

Mirrors Java Message#getKey. Returns None for keyless messages.

Source

pub fn has_key(&self) -> bool

Mirrors Java Message#hasKey.

Source

pub fn ordering_key(&self) -> Option<&Bytes>

Mirrors Java Message#getOrderingKey. Returns None if unset.

Source

pub fn publish_time_ms(&self) -> u64

Mirrors Java Message#getPublishTime — millis since the UNIX epoch as stamped by the producer’s state machine at queue time.

Source

pub fn event_time_ms(&self) -> u64

Mirrors Java Message#getEventTime. Returns 0 if the producer didn’t stamp one (Java returns 0 in the same situation).

Source

pub fn sequence_id(&self) -> u64

Mirrors Java Message#getSequenceId. The sequence id assigned by the producer’s state machine (visible alongside the broker-assigned message id).

Source

pub fn producer_name(&self) -> &str

Mirrors Java Message#getProducerName.

Source

pub fn property(&self, key: &str) -> Option<&str>

Mirrors Java Message#getProperty(String). Returns the value for the first matching property entry, or None if absent.

Source

pub fn properties(&self) -> impl Iterator<Item = (&str, &str)>

Mirrors Java Message#getProperties — every (key, value) pair on the message.

Source

pub fn redelivery_count(&self) -> u32

Mirrors Java Message#getRedeliveryCount. The broker-side count of how many times this message has been redelivered.

Source

pub fn replicated_from(&self) -> Option<&str>

Mirrors Java Message#getReplicatedFrom. None if the message wasn’t replicated.

Source

pub fn is_replicated(&self) -> bool

Mirrors Java Message#isReplicated. true if this message was geo-replicated from another cluster — equivalent to replicated_from().is_some().

Source

pub fn is_batched(&self) -> bool

true if the message arrived as part of a batched entry. The position within the batch is on id.batch_index. Useful for partial-batch ack logic and telemetry.

Source

pub fn is_partitioned(&self) -> bool

true if the message arrived on a partitioned topic. The partition index is on id.partition.

Source

pub fn size(&self) -> usize

Payload size in bytes (post-decompression / post-decryption). Mirrors Java Message#size. Equivalent to self.payload.len().

Source

pub fn is_empty(&self) -> bool

true if the payload is empty — the Pulsar convention for a tombstone in a compacted topic. Mirrors Java Message#isEmpty.

Source

pub fn has_replicate_to(&self) -> bool

Mirrors Java Message#hasReplicateTo. true when the producer stamped an explicit replication cluster list (via OutgoingMessage::replication_clusters / disable_replication).

Source

pub fn replicate_to(&self) -> &[String]

Mirrors Java Message#getReplicateTo. Returns the cluster ids the message was pinned to, or an empty slice when the producer used the namespace default.

Source

pub fn has_event_time(&self) -> bool

Mirrors Java Message#hasEventTime. true if the producer stamped a non-zero event-time (Java distinguishes “unset” from “stamped 0” via this predicate).

Source

pub fn has_ordering_key(&self) -> bool

Mirrors Java Message#hasOrderingKey.

Source

pub fn has_property(&self, key: &str) -> bool

Mirrors Java Message#hasProperty(String).

Source

pub fn has_properties(&self) -> bool

Mirrors Java Message#hasPropertiestrue if the message carries at least one (key, value) property entry.

Source

pub fn schema_version(&self) -> Option<&[u8]>

Mirrors Java Message#getSchemaVersion. None for messages produced by schemaless producers (or via auto-produce-bytes).

Source

pub fn broker_publish_time_ms(&self) -> Option<u64>

PIP-90 broker timestamp — wall-clock millis since epoch the broker assigned when it persisted the entry. Returns None when the namespace policy disables broker-entry metadata or the broker is older than PIP-90.

Source

pub fn broker_index(&self) -> Option<u64>

PIP-90 per-topic broker index — monotonic offset the broker assigned when it persisted the entry. None under the same conditions as Self::broker_publish_time_ms.

Source

pub fn has_encryption(&self) -> bool

true if the message metadata carries PIP-4 encryption context (one or more wrapped symmetric keys + the encryption algorithm name). Useful for callers running with CryptoFailureAction::Consume who want to know whether they need to attempt out-of-band decryption.

Source

pub fn encryption_algorithm(&self) -> Option<&str>

PIP-4 encryption algorithm name (e.g. "AES/GCM/NoPadding"). None if the producer did not encrypt this message.

Source

pub fn encryption_keys(&self) -> &[EncryptionKeys]

PIP-4 wrapped symmetric-key entries. Empty slice when the producer did not encrypt this message. Each entry carries the key name + the ciphertext-wrapped data key the broker echoed back from the producer’s CryptoKeyReader.

Source

pub fn encryption_param(&self) -> Option<&[u8]>

PIP-4 encryption parameter bytes (typically the AES GCM IV/nonce). None if the producer did not encrypt this message.

Trait Implementations§

Source§

impl Clone for IncomingMessage

Source§

fn clone(&self) -> IncomingMessage

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for IncomingMessage

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl From<IncomingMessage> for IncomingMessage

Source§

fn from(msg: IncomingMessage) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more