C# Class KafkaNet.Consumer

Provides a basic consumer of one Topic across all partitions or over a given whitelist of partitions. TODO: provide automatic offset saving when the feature is available in 0.8.2 https://cwiki.apache.org/confluence/display/KAFKA/A+Guide+To+The+Kafka+Protocol#AGuideToTheKafkaProtocol-OffsetCommit/FetchAPI
Inheritance: IMetadataQueries
Show file Open project: gigya/KafkaNetClient Class Usage Examples

Public Methods

Method Description
Consume ( CancellationToken cancellationToken = null ) : IEnumerable

Returns a blocking enumerable of messages received from Kafka.

Consumer ( ConsumerOptions options ) : KafkaNet.Model
Dispose ( ) : void
GetOffsetPosition ( ) : List

Get the current running position (offset) for all consuming partition.

Will only return data if the consumer is actively being consumed.

GetTopicFromCache ( string topic ) : KafkaNet.Protocol.Topic
GetTopicOffsetAsync ( string topic, int maxOffsets = 2, int time = -1 ) : Task>
SetOffsetPosition ( ) : void

Force reset the offset position for a specific partition to a specific offset value.

Private Methods

Method Description
ConsumeTopicPartitionAsync ( string topic, int partitionId ) : Task
EnsurePartitionPollingThreads ( ) : void
FixOffsetOutOfRangeExceptionAsync ( Fetch request ) : void
HandleResponseErrors ( Fetch request, FetchResponse response ) : void

Method Details

Consume() public method

Returns a blocking enumerable of messages received from Kafka.
public Consume ( CancellationToken cancellationToken = null ) : IEnumerable
cancellationToken System.Threading.CancellationToken
return IEnumerable

Consumer() public method

public Consumer ( ConsumerOptions options ) : KafkaNet.Model
options KafkaNet.Model.ConsumerOptions
return KafkaNet.Model

Dispose() public method

public Dispose ( ) : void
return void

GetOffsetPosition() public method

Get the current running position (offset) for all consuming partition.
Will only return data if the consumer is actively being consumed.
public GetOffsetPosition ( ) : List
return List

GetTopicFromCache() public method

public GetTopicFromCache ( string topic ) : KafkaNet.Protocol.Topic
topic string
return KafkaNet.Protocol.Topic

GetTopicOffsetAsync() public method

public GetTopicOffsetAsync ( string topic, int maxOffsets = 2, int time = -1 ) : Task>
topic string
maxOffsets int
time int
return Task>

SetOffsetPosition() public method

Force reset the offset position for a specific partition to a specific offset value.
public SetOffsetPosition ( ) : void
return void