{"id":37014433,"url":"https://github.com/bitleak/php-consumergroup","last_synced_at":"2026-01-14T01:25:42.261Z","repository":{"id":62526933,"uuid":"77213250","full_name":"bitleak/php-consumergroup","owner":"bitleak","description":"The php kafka consumer library with group rebalance","archived":false,"fork":false,"pushed_at":"2019-12-13T06:09:20.000Z","size":32,"stargazers_count":47,"open_issues_count":0,"forks_count":4,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-08-19T08:16:37.897Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bitleak.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-12-23T09:08:16.000Z","updated_at":"2021-03-03T13:00:45.000Z","dependencies_parsed_at":"2022-11-02T16:01:18.688Z","dependency_job_id":null,"html_url":"https://github.com/bitleak/php-consumergroup","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/bitleak/php-consumergroup","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bitleak%2Fphp-consumergroup","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bitleak%2Fphp-consumergroup/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bitleak%2Fphp-consumergroup/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bitleak%2Fphp-consumergroup/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bitleak","download_url":"https://codeload.github.com/bitleak/php-consumergroup/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bitleak%2Fphp-consumergroup/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28407696,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T00:40:43.272Z","status":"ssl_error","status_checked_at":"2026-01-14T00:40:42.636Z","response_time":56,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-01-14T01:25:41.542Z","updated_at":"2026-01-14T01:25:42.241Z","avatar_url":"https://github.com/bitleak.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# php-consumergroup\n\nphp-consumergroup is a kafka consumer library with group and rebalance supports.\n\n[Chinese Doc](./README.zh-CN.md)\n\n## Requirements\n\n* Apache Kafka 0.7.x, 0.8.x, 0.9.x, 0.10.x\n\n## Dependencies\n\n* [php-zookeeper](https://github.com/php-zookeeper/php-zookeeper)\n* [php_rdkafka](https://github.com/arnaud-lb/php-rdkafka/releases/tag/1.0.0) (1.0.0 is recommended)\n* [librdkafka](https://github.com/edenhill/librdkafka/releases/tag/0.9.1) (0.9.1 is recommended)\n\n## Performance\n\n`78,000+` messages/s for single process\n\nmore detail  [benchmark](#benchmark)\n\n## Example\n\n* installing this library via composer\n\n```\n\u003c?php \nuse MTKafka\\Consumer;\n\nfunction call_back_func($msg) {\n    echo \"$msg-\u003epayload\\n\";\n}\n\nfunction handle_error_call_back($msg) {\n    echo $msg-\u003eerrstr();\n}\n\n$consumer = New Consumer(\"localhost:2181\");\n$consumer-\u003esetGroupId(\"group-test\");\n$consumer-\u003esetTopic(\"topic-test\");\n$consumer-\u003esetOffsetAutoReset(Consumer::SMALLEST);\n$consumer-\u003esetErrHandler(\"handle_error_call_back\");\n\ntry {\n    $consumer-\u003estart(\"echo_message\");\n}\ncatch(Exception $e) {\n    printf(\"error: %s\\n\", $e-\u003egetMessage());\n}\n```\n\nsee [example.php](./example.php)\n\n## Consumer Options\n\n##### Consumer::setMaxMessage()\n\nNumber, defaults to `32`\n\nIf partitions \u003e 1, it forces consumers to switch to other partitons when max message is reached, or other partitons will be starved\n\n##### Consumer::setCommitInterval()\n\nMillisecond, defaults to `500ms`\n\nOffset auto commit interval.\n\n##### Consumer::setWatchInterval()\n\nMillisecond, defaults to `10,000 ms`\n\nTime interval to check rebalance. Rebalance is triggered when the number of partition or consumer changes.\n\n##### Consumer::setConsumeTimeout()\n\nMillisecond, default is `1,000 ms`\n\nKafka request timeout.\n\n##### Consumer::setClientId()\n\nString, defaults to `\"default\"`\n\nClient id is used to identify consumers. \n\n##### Consumer::setOffsetAutoReset()\n\n`smallest|largest`, defaults to `smallest`\n\nConsumer can choose whether to fetch the oldest or the lastest message when offset isn't present in zookeeper or is out of range.\n\n##### Consumer::setConf()\nAttribute and value are passed in\n\nWe can use this function to modify the librdkafka configuration。\n\nmore detail about [librdkafka configuration](https://github.com/edenhill/librdkafka/blob/master/CONFIGURATION.md). \n\n## Exception\n\n* Recoverable exceptption (e.g. request timeout), error handler will be called, and you can log error messages.\n* Unrecoverable exception (e.g. kafka/zookeeper is broken), exceptions will be thrown, and you should log message and stop the consumer.\n\n## Benchmark\n\n|Type|Parmeter|\n|---|---|\n|CPU|Intel(R) Xeon(R) CPU E5-2420 0 @ 1.90GHz|\n|CPU Core|24|\n|Memory|16G|\n|Disk|SSD|\n|Network|1000Mbit/s|\n|Os|CentOS release 6.7|\n\nBenchmark is measured by produring `20,000,000` messages at single partition, and calculate the time it takes to consume those messages.\n\nQPS is `78,000` messages/s when process cpu utility is `100%`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbitleak%2Fphp-consumergroup","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbitleak%2Fphp-consumergroup","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbitleak%2Fphp-consumergroup/lists"}