Struct rdkafka::consumer::stream_consumer::StreamConsumer
[−]
[src]
#[must_use = "Consumer polling thread will stop immediately if unused"]pub struct StreamConsumer<C: ConsumerContext + 'static> { /* fields omitted */ }
A Consumer with an associated polling thread. This consumer doesn't need to
be polled and it will return all consumed messages as a Stream
.
Due to the asynchronous nature of the stream, some messages might be consumed by the consumer
without being processed on the other end of the stream. If auto commit is used, it might cause
message loss after consumer restart. Manual offset storing should be used, see the store_offset
function on Consumer
.
Methods
impl<C: ConsumerContext> StreamConsumer<C>
[src]
fn start(&self) -> MessageStream<C>
Starts the StreamConsumer with default configuration (100ms polling interval and no
NoMessageReceived
notifications).
fn start_with(
&self,
poll_interval: Duration,
no_message_error: bool
) -> MessageStream<C>
&self,
poll_interval: Duration,
no_message_error: bool
) -> MessageStream<C>
Starts the StreamConsumer with the specified poll interval. Additionally, if
no_message_error
is set to true, it will return an error of type
KafkaError::NoMessageReceived
every time the poll interval is reached and no message
has been received.
fn stop(&self)
Stops the StreamConsumer, blocking the caller until the internal consumer has been stopped.
Trait Implementations
impl<C: ConsumerContext> Consumer<C> for StreamConsumer<C>
[src]
fn get_base_consumer(&self) -> &BaseConsumer<C>
Returns a reference to the BaseConsumer.
fn subscribe(&self, topics: &Vec<&str>) -> KafkaResult<()>
Subscribe the consumer to a list of topics.
fn assign(&self, assignment: &TopicPartitionList) -> KafkaResult<()>
Manually assign topics and partitions to the consumer.
fn commit(
&self,
topic_partition_list: Option<&TopicPartitionList>,
mode: CommitMode
) -> KafkaResult<()>
&self,
topic_partition_list: Option<&TopicPartitionList>,
mode: CommitMode
) -> KafkaResult<()>
Commit offsets on broker for the provided list of partitions, or the underlying consumers state if None
. If mode is set to CommitMode::Sync, the call will block until the message has been successfully committed. Read more
fn commit_message(
&self,
message: &BorrowedMessage,
mode: CommitMode
) -> KafkaResult<()>
&self,
message: &BorrowedMessage,
mode: CommitMode
) -> KafkaResult<()>
Commit a specific message. If mode is set to CommitMode::Sync, the call will block until the message has been successfully committed. Read more
fn store_offset(&self, message: &BorrowedMessage) -> KafkaResult<()>
Store offset for this message to be used on the next (auto)commit. When using this enable.auto.offset.store
should be set to false
in the config. Read more
fn subscription(&self) -> KafkaResult<TopicPartitionList>
Returns the current topic subscription.
fn assignment(&self) -> KafkaResult<TopicPartitionList>
Returns the current partition assignment.
fn committed(&self, timeout_ms: i32) -> KafkaResult<TopicPartitionList>
Retrieve committed offsets for topics and partitions.
fn offsets_for_timestamp(
&self,
timestamp: i64,
timeout_ms: i32
) -> KafkaResult<TopicPartitionList>
&self,
timestamp: i64,
timeout_ms: i32
) -> KafkaResult<TopicPartitionList>
Lookup the offsets for this consumer's partitions by timestamp.
fn position(&self) -> KafkaResult<TopicPartitionList>
Retrieve current positions (offsets) for topics and partitions.
fn fetch_metadata(
&self,
topic: Option<&str>,
timeout_ms: i32
) -> KafkaResult<Metadata>
&self,
topic: Option<&str>,
timeout_ms: i32
) -> KafkaResult<Metadata>
Returns the metadata information for the specified topic, or for all topics in the cluster if no topic is specified. Read more
fn fetch_watermarks(
&self,
topic: &str,
partition: i32,
timeout_ms: i32
) -> KafkaResult<(i64, i64)>
&self,
topic: &str,
partition: i32,
timeout_ms: i32
) -> KafkaResult<(i64, i64)>
Returns the metadata information for all the topics in the cluster.
fn fetch_group_list(
&self,
group: Option<&str>,
timeout_ms: i32
) -> KafkaResult<GroupList>
&self,
group: Option<&str>,
timeout_ms: i32
) -> KafkaResult<GroupList>
Returns the group membership information for the given group. If no group is specified, all groups will be returned. Read more
impl FromClientConfig for StreamConsumer<EmptyConsumerContext>
[src]
fn from_config(
config: &ClientConfig
) -> KafkaResult<StreamConsumer<EmptyConsumerContext>>
config: &ClientConfig
) -> KafkaResult<StreamConsumer<EmptyConsumerContext>>
impl<C: ConsumerContext> FromClientConfigAndContext<C> for StreamConsumer<C>
[src]
Creates a new Consumer
starting from a ClientConfig
.
fn from_config_and_context(
config: &ClientConfig,
context: C
) -> KafkaResult<StreamConsumer<C>>
config: &ClientConfig,
context: C
) -> KafkaResult<StreamConsumer<C>>