Skip to content

[Feature Request]: Allow consumers to start consuming from specified offset #584

@Waddas

Description

@Waddas

Is your request related to a problem you have?

I need to be able to tell the consumers to start from a specified offset. This is implemented in Confluent Kafka by calling Assign with a TopicPartitionOffset.

Describe the solution you'd like

There is currently the ability to set ManualAssignPartitions in the Consumer Configuration, It would be nice to also have ManualAssignPartitionOffsets. Configuration would look like:

consumer.ManualAssignPartitionOffsets("my-topic", new Dictionary<int, long> { { 0, 100 }, { 1, 120 } })

The implementation would look like:

private void ManualAssignPartitionOffsets(IEnumerable<TopicPartitionOffsets> topics)
    {
        var partitionOffsets = topics
            .SelectMany(
                topic => topic.PartitionOffsets.Select(
                    partitionOffset => new Confluent.Kafka.TopicPartitionOffset(
                        topic.Name, new Partition(partitionOffset.Key), new Offset(partitionOffset.Value))))
            .ToList();

        _consumer.Assign(partitionOffsets);

Are you able to help bring it to life and contribute with a Pull Request?

Yes

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions