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 nack(false) are advisory
no-ops, and nack(true) reports AckError::Unsupported: nothing brings the record back.
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.nack(true)hands the delivery back to its subscription, which delivers it again ahead of what it fetches next. Its offset stays unsettled meanwhile, so the committed position stays below it: were the process to stop first, Kafka redelivers the record from there to whoever reads the partition next. A rebalance or a seek that moves the partition before the delivery comes back drops it for the same reason. Until it settles, the unsettled offset also blocks the position, keeping every later ack uncommitted.
Under Commit::Transactional the settlements report to the exactly-once pipeline instead,
and nack(true) keeps the open window from committing: it aborts, and its replay delivers
the record again with the rest of the window.
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.
Read from the record on the ask rather than carried by the delivery: librdkafka answers it out of the fetch buffer this delivery holds open, and most deliveries are never asked.
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 BuildBatchContext<KafkaMessage> for KafkaBatchContext
impl BuildBatchContext<KafkaMessage> for KafkaBatchContext
Source§fn build(first: &KafkaMessage) -> Self
fn build(first: &KafkaMessage) -> Self
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§fn ack(self) -> impl Future<Output = Result<(), AckError>>
fn ack(self) -> impl Future<Output = Result<(), AckError>>
Marks the offset processed (see the type-level settlement mapping).
§Errors
Returns AckError::Broker when librdkafka refuses the stored position, which is a
client-state failure rather than a network one - the partition is no longer this
consumer’s, say. A descriptor passthrough that would take the offset store back is not
one of those cases and never reaches here: librdkafka would accept the store and keep
owning the position, so Commit::Tracked and
Commit::Transactional refuse such a subscription at
startup instead.
§Cancel safety
Cancel safe: the watermark update is synchronous, so the future either completed or did nothing.
Source§fn nack(self, requeue: bool) -> impl Future<Output = Result<(), AckError>>
fn nack(self, requeue: bool) -> impl Future<Output = Result<(), AckError>>
Settles negatively. requeue = false drops the delivery: the offset settles so the
committed position can move past it. requeue = true hands the delivery back to its
subscription, which delivers it again; its offset stays unsettled until then. Under
Commit::Transactional it aborts the open window, whose replay delivers it again. Under
Commit::Auto requeue = false is an advisory no-op and requeue = true is unsupported
(see the type-level settlement mapping).
Kafka counts no deliveries of its own, so a registration that caps its attempts with
max_attempts(..) gets the framework’s count instead: the runtime republishes the
delivery through the registration’s retry publisher so the count travels with it.
§Errors
Returns AckError::Unsupported for requeue = true under Commit::Auto, where the
position was stored when the record was handed over, and 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 keyed-lane key, so keyed worker lanes see it without a Partitioned bound: the
source partition (the default), or the record key under
LaneKey::RecordKey.
Source§fn redelivery_count(&self) -> Option<u64>
fn redelivery_count(&self) -> Option<u64>
None
where the transport counts nothing. Read moreSource§fn decode_error(&self) -> Option<&CodecError>
fn decode_error(&self) -> Option<&CodecError>
None when it read the delivery
whole. Read moreSource§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 keyed-lane key (see IncomingMessage::partition_key on this type): the source
partition (the default), or the record key under
LaneKey::RecordKey.
Source§impl Positioned for KafkaMessage
impl Positioned for KafkaMessage
Source§fn position(&self) -> Self::Position
fn position(&self) -> Self::Position
This delivery’s own coordinates: seeking to them redelivers exactly this record (and the ordered suffix behind it on the partition).
Source§type Position = KafkaPosition
type Position = KafkaPosition
Seeker::Position.Auto Trait Implementations§
impl !Freeze for KafkaMessage
impl !RefUnwindSafe for KafkaMessage
impl !UnwindSafe for KafkaMessage
impl Send for KafkaMessage
impl Sync for KafkaMessage
impl Unpin for KafkaMessage
impl UnsafeUnpin for KafkaMessage
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more