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§
- Consumer
Commit Failed Error - This error is returned when an offset commit with
Consumer::commit_syncfails 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. - Consumer
Config - The consumer configuration keys
- Consumer
Handle - A
Clone + Send + Synchandle to a consumer that exposesConsumer::wakeup, callable from any task or thread, and the reentrant-safe consumer operations, callable from inside a callback the consumer is running. - Consumer
LogTruncation Error - 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.
- Consumer
NoOffset ForPartition Error - Indicates that there is no stored offset for a partition and no defined offset reset policy.
- Consumer
Offset OutOf Range Error - 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.
- Consumer
Record - 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. - Consumer
Record Options - The parameters of
ConsumerRecord::with_options, built withConsumerRecordOptionsBuilder:topic,partition,offset,keyandvalueare mandatory. - Consumer
Record Options Builder - Fluent builder for
ConsumerRecordOptions: every parameter has a setter, andSelf::buildchecks that the mandatory ones were set. - Consumer
Records - A container that holds the list
ConsumerRecordper partition for a particular topic. There is oneConsumerRecordlist for every topic partition returned by aConsumer::polloperation. - Consumer
Retriable Commit Failed Error - 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.
- Kafka
Consumer - A client that consumes records from a Kafka cluster.
- Mock
Consumer - A mock of the
Consumerinterface you can use for testing code that uses Kafka. This class is not threadsafe. However, you can use theSelf::schedule_poll_taskmethod to write multithreaded tests where a driver thread waits forConsumer::pollto be called by a background thread and then can safely perform operations during a callback. - Offset
AndMetadata - 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.
- Offset
AndTimestamp - A container class for offset and timestamp.
- Subscription
Pattern - Represents a regular expression compatible with Google RE2/J, used to
subscribe to topics. This just keeps the
Stringrepresentation of the pattern, and all validations to ensure it is RE2/J compatible are delegated to the broker.
Enums§
- Group
Protocol - Enum representing the supported consumer group protocols.
Traits§
- Consumer
- The consumer interface, implemented by
KafkaConsumerandMockConsumer. - Consumer
Group Metadata - A metadata struct containing the consumer group information.
- Consumer
Interceptor - 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.
- Consumer
Rebalance Listener - 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>>.