salebab / phpkafka Goto Github PK
View Code? Open in Web Editor NEWPHP extension for Apache Kafka
License: MIT License
PHP extension for Apache Kafka
License: MIT License
when i 'make' phpkafka, it occured the followed issue:
[root@OA-test phpkafka]# make test
Build complete.
Don't forget to run 'make test'.
PHP Warning: PHP Startup: Unable to load dynamic library '/root/phpkafka/modules/kafka.so' - librdkafka.so.1: cannot open shared object file: No such file or directory in Unknown on line 0
Warning: PHP Startup: Unable to load dynamic library '/root/phpkafka/modules/kafka.so' - librdkafka.so.1: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library '/root/phpkafka/modules/kafka.so' - librdkafka.so.1: cannot open shared object file: No such file or directory in Unknown on line 0
Warning: PHP Startup: Unable to load dynamic library '/root/phpkafka/modules/kafka.so' - librdkafka.so.1: cannot open shared object file: No such file or directory in Unknown on line 0
how can i solve it??? please help me
ldd /usr/lib/php5/20100525/kafka.so
linux-vdso.so.1 => (0x00007fff2bdff000)
librdkafka.so.1 => not found
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f90d3d42000)
/lib64/ld-linux-x86-64.so.2 (0x00007f90d430f000)
echo time();
produce("test", $i); ``` } echo "\n".time();Hello,
I already install both phpkafka and librdkafka and it seems that the installation went well. Even following the steps you suggested in README.md I solved the problem of "Unable to load dynamic library '/usr/lib64/php/modules/kafka.so' - librdkafka.so.1".
Now, when I try to execute the sample code I get this error "PHP Fatal error: Class 'Kafka' not found in /var/www/html/kafka-test.php on line 3"
What am I missing?
Why PHP does not recognize the class Kafka?
Is there some specific place where I have to put my code within my public directory?
The code I'm using is below, I really appreciate any help on this.
produce("topic_name", "message content"); //get all the available partitions $partitions = $kafka->getPartitionsForTopic('topic_name'); //use it to OPTIONALLY specify a partition to consume from //if not, consuming IS slower. To set the partition: $kafka->setPartition($partitions[0]);//set to first partition //then consume, for example, starting with the first offset, consume 20 messages $msg = $kafka->consume("topic_name", Kafka::OFFSET_BEGIN, 20); var_dump($msg);//dumps array of messages@EVODelavega
Hi EVODelavega,
Can I ask some questions about offset which I am not quite sure about when I utilize phpkafka client:
https://github.com/EVODelavega/phpkafka
For consuming messages, I store the offset of each topic partition in files, wrote a php script, which reads offset from the file, and then invokes function consume with the offset as parameter, after that, I will update the offset in the file by adding the message count which are consumed this time to the previous offset. Besides, I add a crontab in the server for executing that php script everything minute.
To be more concrete, if the offset in the file is 5, and 20 messages are consumed this time, the I will update the offset in that file to be 25. I update the offset each time messages are consumed because I do not want to consume same message repeatedly.
I am not sure if my solution of consumer is good or not, what I worry about is, for kafka broker, it will delete old log(segment) by some policy, I did not modify the default configuration of broker, so it will delete any log with a modification time of more than 7 days ago.
If the old logs are deleted by broker, not sure if the offset stored in the file will be incorrect.
Have you come across the same problem? Could you give me some suggestion about this ? Is there any better way to record the offset, and deleting old logs will not affect it.
Thanks!
Hi,
is there any api to quickly get the length of each topic message queue? waiting for the answer, thanks!
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.
I am getting the following error while using the php kafka client
It Looks like somehow the produce is getting confused between the topic name and the host name.
The code,
{noformat}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.