pub struct KafkaMessage { /* private fields */ }Expand description
One Kafka delivery: an owned snapshot of the record plus its settlement handle.
Settlement mapping depends on the Commit mode of the subscription:
Under Commit::Auto (the default) librdkafka owns the committed position - it is stored
the moment a message is handed to the application - so ack and both nack forms are
advisory no-ops; in particular nack(true) does NOT cause a redelivery.
Under Commit::Tracked:
acksettles the offset and advances the stored position across everything settled below it.nack(false)drops the message: the offset settles so the position can move past it (Kafka has no per-message dead-letter path; a dead-letter topic is a planned descriptor option).nack(true)leaves the offset unsettled: the committed position stays below it, so Kafka redelivers from there when the partition is next re-fetched (a rebalance or a restart). Until then the unsettled offset also blocks the position, keeping every later ack uncommitted - precise, but worth knowing when a handler nacks in a loop.
Wire headers map name for name; a null-valued Kafka header arrives with an empty value (presence preserved).
Implementations§
Source§impl KafkaMessage
impl KafkaMessage
Sourcepub fn timestamp_millis(&self) -> Option<i64>
pub fn timestamp_millis(&self) -> Option<i64>
The record’s timestamp in milliseconds since the epoch, when the broker provided one.
Sourcepub fn key(&self) -> Option<&[u8]>
pub fn key(&self) -> Option<&[u8]>
The record key, surfaced from Kafka’s native key (see PARTITION_KEY_HEADER).
Trait Implementations§
Source§impl BuildContext<KafkaMessage> for KafkaContext
impl BuildContext<KafkaMessage> for KafkaContext
Source§fn build(msg: &KafkaMessage) -> Self
fn build(msg: &KafkaMessage) -> Self
msg.Source§impl Debug for KafkaMessage
impl Debug for KafkaMessage
Source§impl IncomingMessage for KafkaMessage
impl IncomingMessage for KafkaMessage
Source§async fn ack(self) -> Result<(), AckError>
async fn ack(self) -> Result<(), AckError>
Marks the offset processed (see the type-level settlement mapping).
§Errors
Returns AckError::Broker when the offset store rejects the new position, for example
because enable.auto.offset.store was overridden back to true on a Commit::Tracked
subscription.
§Cancel safety
Cancel safe: the watermark update is synchronous, so the future either completed or did nothing.
Source§async fn nack(self, requeue: bool) -> Result<(), AckError>
async fn nack(self, requeue: bool) -> Result<(), AckError>
Settles negatively: drops the offset (requeue = false) or leaves it unsettled for
Kafka’s native re-consumption (requeue = true). Only meaningful under
Commit::Tracked; under Commit::Auto both forms are advisory no-ops (see the
type-level settlement mapping).
§Errors
Returns AckError::Broker under the same conditions as ack.
§Cancel safety
Cancel safe: the watermark update is synchronous, so the future either completed or did nothing.
Source§fn partition_key(&self) -> Option<&[u8]>
fn partition_key(&self) -> Option<&[u8]>
The record key, so keyed worker lanes see it without a Partitioned bound.
Source§fn supports_nack_after(&self) -> bool
fn supports_nack_after(&self) -> bool
nack_after natively. Read moreSource§impl Partitioned for KafkaMessage
impl Partitioned for KafkaMessage
Source§fn partition_key(&self) -> Option<&[u8]>
fn partition_key(&self) -> Option<&[u8]>
The record key Kafka partitioned this message by, or None for keyless records.