Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[v2.x] Partition assignment #234

Merged
merged 8 commits into from
Jan 9, 2024
Merged

[v2.x] Partition assignment #234

merged 8 commits into from
Jan 9, 2024

Conversation

mateusjunges
Copy link
Owner

@mateusjunges mateusjunges commented Jan 9, 2024

Kafka Clients allows you to implement your own partition assignment strategies for consumers.

This PR allows to specify which partitions a consumer should consume from.

In the following example, this consumer will only consume messages from the my-awesome-topic partitions 2, and 3. Messages from any other partition won't be handled by this consumer.

Kafka::createConsumer()
    ->assignPartitions([
        new TopicPartition('my-awesome-topic', 2),
        new TopicPartition('my-awesome-topic', 3),
    ])
    ->withHandler(function (ConsumedMessage $message) {
        // Handle the message here
    })->build();

$consumer->consume();

@mateusjunges mateusjunges self-assigned this Jan 9, 2024
@mateusjunges mateusjunges changed the title Partition assignment [v2.x] Partition assignment Jan 9, 2024
@mateusjunges mateusjunges linked an issue Jan 9, 2024 that may be closed by this pull request
@mateusjunges mateusjunges marked this pull request as ready for review January 9, 2024 20:02
…ment

# Conflicts:
#	src/Config/Config.php
#	src/Consumers/ConsumerBuilder.php
@mateusjunges mateusjunges merged commit 389b06d into v2.x Jan 9, 2024
4 checks passed
@mateusjunges mateusjunges deleted the feat/partition-assignment branch January 9, 2024 20:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Consumer not working with multiple partition from producer?
1 participant