Interface IKafkaConsumer
- Namespace
- Silverback.Messaging.Broker
- Assembly
- Silverback.Integration.Kafka.dll
Consumes from one or more endpoints and pushes the received messages via the message bus.
public interface IKafkaConsumer : IConsumer
- Inherited Members
Properties
Client
Gets the related IBrokerClient.
IConfluentConsumerWrapper Client { get; }
Property Value
Configuration
Gets the consumer configuration.
KafkaConsumerConfiguration Configuration { get; }
Property Value
EndpointsConfiguration
Gets the endpoints configuration.
IReadOnlyCollection<KafkaConsumerEndpointConfiguration> EndpointsConfiguration { get; }
Property Value
Methods
GetOffsetsForTimestamps(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> GetOffsetsForTimestamps(IEnumerable<TopicPartitionTimestamp> topicPartitionTimestamps, TimeSpan timeout)
Parameters
topicPartitionTimestampsIEnumerable<TopicPartitionTimestamp>The mapping from partition to the timestamp to look up.
timeoutTimeSpanThe 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.
Exceptions
- InvalidOperationException
The consumer isn't connected.
Pause(IEnumerable<TopicPartition>)
Pauses the consumption of the specified partitions.
void Pause(IEnumerable<TopicPartition> partitions)
Parameters
partitionsIEnumerable<TopicPartition>The list of Confluent.Kafka.TopicPartition to be paused.
Remarks
The consumer pauses a partition itself while rolling back its processing (for example to retry a failed message) and resumes it once sought back to the first message to be processed again: this also resumes a partition that was paused through this method before the rollback.
Exceptions
- InvalidOperationException
The consumer isn't connected.
Resume(IEnumerable<TopicPartition>)
Resumes the consumption of the specified partitions.
void Resume(IEnumerable<TopicPartition> partitions)
Parameters
partitionsIEnumerable<TopicPartition>The list of Confluent.Kafka.TopicPartition to be paused.
Exceptions
- InvalidOperationException
The consumer isn't connected.
Seek(TopicPartitionOffset)
Seeks the specified partition to the specified offset.
void Seek(TopicPartitionOffset topicPartitionOffset)
Parameters
topicPartitionOffsetTopicPartitionOffsetThe offset.
Remarks
The new position also becomes the position from which the partition is consumed again when the consumer is restarted and, if the partitions are processed together (see ProcessPartitionsIndependently), when the processing is rolled back. The records already fetched before the seek may still be processed.
Exceptions
- InvalidOperationException
The consumer isn't connected.
WaitUntilCaughtUpAsync(CancellationToken)
Waits until the consumer is caught up, meaning that every partition assigned to it reached its end and all its messages are processed (see CatchUpMode).
Task WaitUntilCaughtUpAsync(CancellationToken cancellationToken = default)
Parameters
cancellationTokenCancellationTokenA CancellationToken used to cancel the wait.
Returns
Remarks
The task completes before the IKafkaConsumerCaughtUpCallback is invoked. Once the consumer is caught up, the returned task completes right away until a reconnect starts a new catch-up.
Exceptions
- InvalidOperationException
The catch-up isn't enabled (see CatchUpMode).