salebab / phpkafka

PHP extension for Apache Kafka

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Consume function fails

the100rabh opened this issue · comments

I tried running consume function from php in interactive mode and it crashes php. produce function on the other hand works very well.

There are no logs that I can figure out. Any pointers to debug this will help.

@the100rabh I have exactly the same issue, did you find the solution?

Just a tip, I ran into the same issue, but if you look at the source code, you'll see that the kafka_consume function (in kafka.c) actually writes its error output to syslog (/var/log/syslog). just run a test-php script, check the exit code (echo $?), if the exit code is anything other than 0, tail the syslog and you'll probably see something like phpkafka - % Failed to start consuming: Local: Unknown partition show up.

There's also a slight issue with the format specifiers used in the extension, I've gotten output like this:

phpkafka - start_offset: -2 and offset passed: -618028960

which is down to the fact that start_offset is of the type int64_t, and the format specifier is %d (whereas it should be "%" PRId64 "...").

Anyway, call the set_partition method before consuming should fix the problem, it did for me anyway. Meanwhile, I've set about putting together a quick-fix PR here, you can check to see if this fixes the issue by using my fork (branch consume-fix). Just compile and install as normal. It should work just fine