-
Notifications
You must be signed in to change notification settings - Fork 439
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
[kafka] One consumer for multiple kafka topics #832
Comments
As far as I know, you cannot do this using enqueue. php-rdkafka (based on librdkafka) on which php-enqueue/rdkafka is based provides low-level consuming for such cases: $queue = $rk->newQueue();
$topic1 = $rk->newTopic("topic1");
$topic1->consumeQueueStart(0, RD_KAFKA_OFFSET_BEGINNING, $queue);
$topic1->consumeQueueStart(1, RD_KAFKA_OFFSET_BEGINNING, $queue);
$topic2 = $rk->newTopic("topic2");
$topic2->consumeQueueStart(0, RD_KAFKA_OFFSET_BEGINNING, $queue);
while (true) {
$msg = $queue->consume(1000);
} Enqueue library implements only high-level consuming. |
According to example present in the docs: https://arnaud-lb.github.io/php-rdkafka/phpdoc/rdkafka.examples-high-level-consumer.html it is possible to use multiple topics in high level consumer, so we might look into allowing this in some form or another. |
@Steveb-p nice point, my bad. From the source code, I see no other problems to implement this in the rdkafka transport except than:
What do you think about mentioned caveats? Thank you in advance for the answers. |
@Sevavietl I wasn't considering what changes to existing code should be made for it to work, or if it even makes sense considering other implementations (of enqueue queues). To be frank, I was almost sure one cannot use multiple topics in high level consumer myself. As far as 2. is concerned, dsn should be perfectly capable of handling it. Specifically, All that would be required is to always treat topic as array and convert single topic into an array if passed. There might be some more configuration changes that need to be done, I just skimmed through what came to my mind. |
@Steveb-p thank you for the prompt response. I would be glad to help with this functionality, will try to create the PR |
@Sevavietl did you have time to look into this? Or can I take it over? |
@Steveb-p I have looked into, but have not implemented it into PR yet, so if you want you can take it over. |
@Sevavietl I’m available on php-enqueue’s gitter most od the time :) |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Hi stale-bot, be quiet please ;) |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
I know I'm a little late for the party, but I just faced the same problem. I noticed that you are able to use a regex as a queue/topic name. You just have to prefix it with ^ |
+1, having the ability to subscribe to multiple topics at once would be very helpful |
sry, any update on this ? |
I have several topics which are being populated by a separate app. Is there a way to consume from all of them by one consumer?
The text was updated successfully, but these errors were encountered: