php kafka rdkafka扩展使用

2020-9-7 14:18:37 星期一

PHP官方的kafka扩展是 rdkafka;

kafka PHP官方扩展文档: https://arnaud.le-blanc.net/php-rdkafka-doc/phpdoc/book.rdkafka.html
kafka 配置项的官方说明: https://github.com/edenhill/librdkafka/blob/master/CONFIGURATION.md
下载扩展: http://pecl.php.net/package/rdkafka
windows 安装扩展: https://arnaud.le-blanc.net/php-rdkafka-doc/phpdoc/rdkafka.installation.windows.html

4.0以后的版本有一个重要改动:

BREAKING CHANGE: Since version 4.0, the client no longer polls for network
events at shutdown (during object destructor). This behaviour didn't give
enough control to the user in case of server issue, and could cause the script
to hang while terminating.

Starting from 4.0, programs MUST call flush() before shutting down, otherwise
some messages and callbacks may be lost.

简单翻译一下: 

对于4.0以后的版本, 客户端对象销毁的时候, 不再检查处理(poll)网络事件了, 因为如果服务器有问题, 用户也干不了啥, 而且会导致脚本挂起;

以后在程序停掉之前必须调用 flush()方法, 否则会导致消息丢失.

==============

如果报错 Segmentation fault (core dumped)  检查一下是不是topic没有配置或者其他配置项配置错误了 (php5.6 rdkafka 4.0.2)

 

posted @ 2020-09-07 14:37  myD  阅读(1165)  评论(0编辑  收藏  举报