Skip to main content

Module consumer

Module consumer 

Source
Expand description

Consumer types (org.apache.kafka.clients.consumer).

Translated from org.apache.kafka.clients.consumer. The clients Java package segment is intentionally dropped per CLAUDE.md §2.

Re-exports§

pub use close_options::CloseOptions;
pub use close_options::GroupMembershipOperation;
pub use offset_commit_callback::OffsetCommitCallback;

Modules§

close_options
Options for closing a consumer.
consumer_partition_assignor
Data holders for the consumer partition assignor protocol.
offset_commit_callback
Callback interface notified when an async offset commit completes.

Structs§

ConsumerCommitFailedError
This error is returned when an offset commit with Consumer::commit_sync fails with an unrecoverable error. This error is generated on the client side, typically when a group rebalance completes before the commit could be successfully applied. In this case, the commit cannot generally be retried because some of the partitions may have already been assigned to another member in the group.
ConsumerConfig
The consumer configuration keys
ConsumerHandle
A Clone + Send + Sync handle to a consumer that exposes Consumer::wakeup, callable from any task or thread, and the reentrant-safe consumer operations, callable from inside a callback the consumer is running.
ConsumerLogTruncationError
In the event of an unclean leader election, the log will be truncated, previously committed data will be lost, and new data will be written over these offsets. When this happens, the consumer will detect the truncation and return this error (if no automatic reset policy has been defined) with the first offset known to diverge from what the consumer previously read.
ConsumerNoOffsetForPartitionError
Indicates that there is no stored offset for a partition and no defined offset reset policy.
ConsumerOffsetOutOfRangeError
No reset policy has been defined, and the offsets for these partitions are either larger or smaller than the range of offsets the server has for the given partition.
ConsumerRecord
A key/value pair to be received from Kafka. This also consists of a topic name and a partition number from which the record is being received, an offset that points to the record in a Kafka partition, and a timestamp as marked by the corresponding ProducerRecord.
ConsumerRecordOptions
The parameters of ConsumerRecord::with_options, built with ConsumerRecordOptionsBuilder: topic, partition, offset, key and value are mandatory.
ConsumerRecordOptionsBuilder
Fluent builder for ConsumerRecordOptions: every parameter has a setter, and Self::build checks that the mandatory ones were set.
ConsumerRecords
A container that holds the list ConsumerRecord per partition for a particular topic. There is one ConsumerRecord list for every topic partition returned by a Consumer::poll operation.
ConsumerRetriableCommitFailedError
Error returned when an offset commit fails with a retriable error. This error is generated on the client side upon receiving retriable error codes from the Group Coordinator in a commit response.
KafkaConsumer
A client that consumes records from a Kafka cluster.
MockConsumer
A mock of the Consumer interface you can use for testing code that uses Kafka. This class is not threadsafe. However, you can use the Self::schedule_poll_task method to write multithreaded tests where a driver thread waits for Consumer::poll to be called by a background thread and then can safely perform operations during a callback.
OffsetAndMetadata
The Kafka offset commit API allows users to provide additional metadata (in the form of a string) when an offset is committed. This can be useful (for example) to store information about which node made the commit, what time the commit was made, etc.
OffsetAndTimestamp
A container class for offset and timestamp.
SubscriptionPattern
Represents a regular expression compatible with Google RE2/J, used to subscribe to topics. This just keeps the String representation of the pattern, and all validations to ensure it is RE2/J compatible are delegated to the broker.

Enums§

GroupProtocol
Enum representing the supported consumer group protocols.

Traits§

Consumer
The consumer interface, implemented by KafkaConsumer and MockConsumer.
ConsumerGroupMetadata
A metadata struct containing the consumer group information.
ConsumerInterceptor
A plugin interface that allows you to intercept (and possibly mutate) records received by the consumer. A primary use-case is for third-party components to hook into the consumer applications for custom monitoring, logging, etc.
ConsumerRebalanceListener
A callback interface that the user can implement to trigger custom actions when the set of partitions assigned to the consumer changes.
DynConsumer
A dyn-compatible Consumer, for holding different consumer implementations behind one type, e.g. Box<dyn DynConsumer<K, V>>.