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: MessageIdMessage 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: BytesApplication payload bytes (post-decompression / post-decryption).
redelivery_count: u32Broker-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
impl IncomingMessage
Sourcepub fn key(&self) -> Option<&str>
pub fn key(&self) -> Option<&str>
Mirrors Java Message#getKey. Returns None for keyless messages.
Sourcepub fn ordering_key(&self) -> Option<&Bytes>
pub fn ordering_key(&self) -> Option<&Bytes>
Mirrors Java Message#getOrderingKey. Returns None if unset.
Sourcepub fn publish_time_ms(&self) -> u64
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.
Sourcepub fn event_time_ms(&self) -> u64
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).
Sourcepub fn sequence_id(&self) -> u64
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).
Sourcepub fn producer_name(&self) -> &str
pub fn producer_name(&self) -> &str
Mirrors Java Message#getProducerName.
Sourcepub fn property(&self, key: &str) -> Option<&str>
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.
Sourcepub fn properties(&self) -> impl Iterator<Item = (&str, &str)>
pub fn properties(&self) -> impl Iterator<Item = (&str, &str)>
Mirrors Java Message#getProperties — every (key, value) pair on the message.
Sourcepub fn redelivery_count(&self) -> u32
pub fn redelivery_count(&self) -> u32
Mirrors Java Message#getRedeliveryCount. The broker-side count of how many times
this message has been redelivered.
Sourcepub fn replicated_from(&self) -> Option<&str>
pub fn replicated_from(&self) -> Option<&str>
Mirrors Java Message#getReplicatedFrom. None if the message wasn’t replicated.
Sourcepub fn is_replicated(&self) -> bool
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().
Sourcepub fn is_batched(&self) -> bool
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.
Sourcepub fn is_partitioned(&self) -> bool
pub fn is_partitioned(&self) -> bool
true if the message arrived on a partitioned topic. The partition index is on
id.partition.
Sourcepub fn size(&self) -> usize
pub fn size(&self) -> usize
Payload size in bytes (post-decompression / post-decryption). Mirrors Java
Message#size. Equivalent to self.payload.len().
Sourcepub fn is_empty(&self) -> bool
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.
Sourcepub fn has_replicate_to(&self) -> bool
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).
Sourcepub fn replicate_to(&self) -> &[String]
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.
Sourcepub fn has_event_time(&self) -> bool
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).
Sourcepub fn has_ordering_key(&self) -> bool
pub fn has_ordering_key(&self) -> bool
Mirrors Java Message#hasOrderingKey.
Sourcepub fn has_property(&self, key: &str) -> bool
pub fn has_property(&self, key: &str) -> bool
Mirrors Java Message#hasProperty(String).
Sourcepub fn has_properties(&self) -> bool
pub fn has_properties(&self) -> bool
Mirrors Java Message#hasProperties — true if the message carries at least one
(key, value) property entry.
Sourcepub fn schema_version(&self) -> Option<&[u8]>
pub fn schema_version(&self) -> Option<&[u8]>
Mirrors Java Message#getSchemaVersion. None for messages produced by schemaless
producers (or via auto-produce-bytes).
Sourcepub fn broker_publish_time_ms(&self) -> Option<u64>
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.
Sourcepub fn broker_index(&self) -> Option<u64>
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.
Sourcepub fn has_encryption(&self) -> bool
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.
Sourcepub fn encryption_algorithm(&self) -> Option<&str>
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.
Sourcepub fn encryption_keys(&self) -> &[EncryptionKeys]
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.
Sourcepub fn encryption_param(&self) -> Option<&[u8]>
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
impl Clone for IncomingMessage
Source§fn clone(&self) -> IncomingMessage
fn clone(&self) -> IncomingMessage
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more