Table of Contents

Interface IConfluentConsumerWrapper

Namespace
Silverback.Messaging.Broker.Kafka
Assembly
Silverback.Integration.Kafka.dll

Wraps the underlying Confluent.Kafka.IConsumer<TKey, TValue> and handles the connection lifecycle.

public interface IConfluentConsumerWrapper : IBrokerClient, IDisposable, IAsyncDisposable
Inherited Members

Properties

Assignment

Gets the list of partitions currently assigned to this consumer.

IReadOnlyList<TopicPartition> Assignment { get; }

Property Value

IReadOnlyList<TopicPartition>

Configuration

Gets the consumer configuration.

KafkaConsumerConfiguration Configuration { get; }

Property Value

KafkaConsumerConfiguration

Consumer

Gets or sets the related consumer instance.

KafkaConsumer Consumer { get; set; }

Property Value

KafkaConsumer

Methods

Commit()

Commits all stored offsets.

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.

ConsumeResult<byte[]?, byte[]?>? Consume(TimeSpan timeout)

Parameters

timeout TimeSpan

The maximum period of time the call may block.

Returns

ConsumeResult<byte[], byte[]>

The next Confluent.Kafka.ConsumeResult<TKey, TValue>.

GetConsumerGroupMetadata()

Gets the consumer group metadata.

IConsumerGroupMetadata GetConsumerGroupMetadata()

Returns

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.

IReadOnlyList<TopicPartitionOffset> OffsetsForTimes(IEnumerable<TopicPartitionTimestamp> timestampsToSearch, TimeSpan timeout)

Parameters

timestampsToSearch IEnumerable<TopicPartitionTimestamp>

The mapping from partition to the timestamp to look up.

timeout TimeSpan

The maximum period of time the call may block.

Returns

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.

void Pause(IEnumerable<TopicPartition> partitions)

Parameters

partitions IEnumerable<TopicPartition>

The list of Confluent.Kafka.TopicPartition to be paused.

Resume(IEnumerable<TopicPartition>)

Resumes the consumption of the specified partitions.

void Resume(IEnumerable<TopicPartition> partitions)

Parameters

partitions IEnumerable<TopicPartition>

The list of Confluent.Kafka.TopicPartition to be paused.

Seek(TopicPartitionOffset)

Seeks the specified partition to the specified offset.

void Seek(TopicPartitionOffset topicPartitionOffset)

Parameters

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.

void StoreOffset(TopicPartitionOffset topicPartitionOffset)

Parameters

topicPartitionOffset TopicPartitionOffset

The offset to be stored.