Skip to main content
Version: 3.x

IMessageConsumer.GetOffsets method

Look up the offsets for the given partitions by timestamp. The returned offset for each partition is the earliest offset whose timestamp is greater than or equal to the given timestamp in the corresponding partition.

public List<TopicPartitionOffset> GetOffsets(
IEnumerable<TopicPartitionTimestamp> timestampsToSearch, TimeSpan timeout)
parameterdescription
timestampsToSearchThe mapping from partition to the timestamp to look up.
timeoutThe maximum period of time the call may block.

Return Value

A mapping from partition to the timestamp and offset of the first message with timestamp greater than or equal to the target timestamp.

Exceptions

exceptioncondition
KafkaExceptionThrown if the operation fails.
TopicPartitionOffsetExceptionThrown if any of the constituent results is in error. The entire result (which may contain constituent results that are not in error) is available via the Results property of the exception.

Remarks

The consumer does not need to be assigned to the requested partitions.

See Also