Interface IConfluentConsumerWrapper
Wraps the underlying Confluent.Kafka.IConsumer<TKey, TValue> and handles the connection lifecycle.
Inherited Members
Namespace: Silverback.Messaging.Broker.Kafka
Assembly: Silverback.Integration.Kafka.dll
Syntax
public interface IConfluentConsumerWrapper : IBrokerClient, IDisposable, IAsyncDisposable
Properties
Assignment
Gets the list of partitions currently assigned to this consumer.
Declaration
IReadOnlyList<TopicPartition> Assignment { get; }
Property Value
| Type | Description |
|---|---|
| IReadOnlyList<TopicPartition> |
Configuration
Gets the consumer configuration.
Declaration
KafkaConsumerConfiguration Configuration { get; }
Property Value
| Type | Description |
|---|---|
| KafkaConsumerConfiguration |
Consumer
Gets or sets the related consumer instance.
Declaration
KafkaConsumer Consumer { get; set; }
Property Value
| Type | Description |
|---|---|
| KafkaConsumer |
Methods
Commit()
Commits all stored offsets.
Declaration
void Commit()
Consume(TimeSpan)
Poll for new messages (or events). This call blocks until a Confluent.Kafka.ConsumeResult<TKey, TValue> is available or the operation has been canceled.
Declaration
ConsumeResult<byte[]?, byte[]?>? Consume(TimeSpan timeout)
Parameters
| Type | Name | Description |
|---|---|---|
| TimeSpan | timeout | The maximum period of time the call may block. |
Returns
| Type | Description |
|---|---|
| ConsumeResult<byte[], byte[]> | The next Confluent.Kafka.ConsumeResult<TKey, TValue>. |
GetConsumerGroupMetadata()
Gets the consumer group metadata.
Declaration
IConsumerGroupMetadata GetConsumerGroupMetadata()
Returns
| Type | Description |
|---|---|
| IConsumerGroupMetadata | The Confluent.Kafka.IConsumerGroupMetadata. |
OffsetsForTimes(IEnumerable<TopicPartitionTimestamp>, TimeSpan)
Looks up the offsets for the given partitions by timestamp. The returned offset for each partition is the earliest offset for which the timestamp is greater than or equal to the given timestamp. If the provided timestamp exceeds that of the last message in the partition, a value of Confluent.Kafka.Offset.End will be returned.
Declaration
IReadOnlyList<TopicPartitionOffset> OffsetsForTimes(IEnumerable<TopicPartitionTimestamp> timestampsToSearch, TimeSpan timeout)
Parameters
| Type | Name | Description |
|---|---|---|
| IEnumerable<TopicPartitionTimestamp> | timestampsToSearch | The mapping from partition to the timestamp to look up. |
| TimeSpan | timeout | The maximum period of time the call may block. |
Returns
| Type | Description |
|---|---|
| IReadOnlyList<TopicPartitionOffset> | A mapping from partition to the timestamp and offset of the first message with timestamp greater than or equal to the target timestamp. |
Remarks
The consumer does not need to be assigned to the requested partitions.
Pause(IEnumerable<TopicPartition>)
Pauses the consumption of the specified partitions.
Declaration
void Pause(IEnumerable<TopicPartition> partitions)
Parameters
| Type | Name | Description |
|---|---|---|
| IEnumerable<TopicPartition> | partitions | The list of Confluent.Kafka.TopicPartition to be paused. |
Resume(IEnumerable<TopicPartition>)
Resumes the consumption of the specified partitions.
Declaration
void Resume(IEnumerable<TopicPartition> partitions)
Parameters
| Type | Name | Description |
|---|---|---|
| IEnumerable<TopicPartition> | partitions | The list of Confluent.Kafka.TopicPartition to be paused. |
Seek(TopicPartitionOffset)
Seeks the specified partition to the specified offset.
Declaration
void Seek(TopicPartitionOffset topicPartitionOffset)
Parameters
| Type | Name | Description |
|---|---|---|
| TopicPartitionOffset | topicPartitionOffset | The offset. |
StoreOffset(TopicPartitionOffset)
Stores the specified offset for the specified partition.
The offset will be committed (written) to the offset store according to AutoCommitIntervalMs
or with a call to the Commit() method.
Declaration
void StoreOffset(TopicPartitionOffset topicPartitionOffset)
Parameters
| Type | Name | Description |
|---|---|---|
| TopicPartitionOffset | topicPartitionOffset | The offset to be stored. |