Git Product home page Git Product logo

phpkafka's People

Contributors

salebab avatar yllierop avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

phpkafka's Issues

Need help to resolve this error

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}

produce("test", $i); } {noformat} %3|1414003292.750|ERROR|rdkafka#producer-0| Failed to resolve 'test:9092': nodename nor servname provided, or not known %3|1414003292.750|GETADDR|rdkafka#producer-0| test:9092/bootstrap: Failed to resolve 'test:9092': nodename nor servname provided, or not known %3|1414003293.758|ERROR|rdkafka#producer-0| Failed to resolve 'test:9092': nodename nor servname provided, or not known %3|1414003293.758|GETADDR|rdkafka#producer-0| test:9092/bootstrap: Failed to resolve 'test:9092': nodename nor servname provided, or not known %3|1414003294.766|ERROR|rdkafka#producer-0| Failed to resolve 'test:9092': nodename nor servname provided, or not known %3|1414003294.766|GETADDR|rdkafka#producer-0| test:9092/bootstrap: Failed to resolve 'test:9092': nodename nor servname provided, or not known %3|1414003295.774|ERROR|rdkafka#producer-0| Failed to resolve 'test:9092': nodename nor servname provided, or not known %3|1414003295.774|GETADDR|rdkafka#producer-0| test:9092/bootstrap: Failed to resolve 'test:9092': nodename nor servname provided, or not known

Consume function fails

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.

PHP Fatal error: Class 'Kafka' not found in /var/www/html/kafka-test.php on line 3

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

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

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

Problems about offset

@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

  1. Does phpkafka client store offset of each topic partition? I have a try on function getPartitionsForTopic in Kafka.class.php, but it does not work.
  2. For consuming message by invoking function consume($topic, $offset = self::OFFSET_BEGIN, $count = self::OFFSET_END), we must tell it the offset, right ?

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!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.