These are chat archives for arnaud-lb/php-rdkafka

11th
Sep 2018
sonalithakkar
@sonalithakkar
Sep 11 2018 05:47
@karavzeka for ($i = 0; $i < 50; $i++) {
$message = $consumer->consume(120*1000);
switch ($message->err) {
case RD_KAFKA_RESP_ERR_NO_ERROR:
echo $message->payload . "\n";
break;
case RD_KAFKA_RESP_ERRPARTITION_EOF:
echo "No more messages; will wait for more\n";
break;
case RD_KAFKA_RESP_ERR
TIMED_OUT:
echo "Timed out\n";
break;
default:
throw new \Exception($message->errstr(), $message->err);
break;
}
}
but here how we know count of message?
as it is dynamic
karavzeka
@karavzeka
Sep 11 2018 06:29
It's only example. I put 50 messages, so I know how many consumes I need. Of course you should use while cycle in a real project.
sonalithakkar
@sonalithakkar
Sep 11 2018 06:35
using while i get issue which i have posted here. All message consumed by first consumer only.
karavzeka
@karavzeka
Sep 11 2018 06:42
Do you replace for with while in 1st example?
sonalithakkar
@sonalithakkar
Sep 11 2018 06:53
I have tried it previously. Will check with your example also
karavzeka
@karavzeka
Sep 11 2018 06:55
Of course if you do it, first while will hold the script.
sonalithakkar
@sonalithakkar
Sep 11 2018 06:55
ok
One more thing i want to confirm that is cron job replaced with kafka and if yes how to implement in php
karavzeka
@karavzeka
Sep 11 2018 06:58
Kafka and cron are incompatible. Consumer scripts should be run as daemons.
sonalithakkar
@sonalithakkar
Sep 11 2018 06:59
Is it possible to run consumer as deamon?
karavzeka
@karavzeka
Sep 11 2018 07:00
In real project you don't have another way.
sonalithakkar
@sonalithakkar
Sep 11 2018 07:02
ohhk tahnks
karavzeka
@karavzeka
Sep 11 2018 07:02
No, I've lied. Another way is threads. But it 's not your level, I think.
sonalithakkar
@sonalithakkar
Sep 11 2018 07:03
means can you elaborate on this