• php 使用kafka


    <?php
    
    $conf = new RdKafkaConf();
    //捕获错误的回调
    $conf->setErrorCb(function ($kafka, $err, $reason) {
        Log::error('kafkaError', ['errorStr' => rd_kafka_err2str($err), 'err' => $err, 'reason' => $reason, 'content' => $kafka]);
    });
    
    $rk = new RdKafkaProducer($conf);
    $rk->setLogLevel(LOG_DEBUG);
    $rk->addBrokers($this->url);
    
    $topic = $rk->newTopic($this->topic);
    //写kafka
    $topic->produce(RD_KAFKA_PARTITION_UA, 0, $str);
    $rk->poll(0);
    欢迎大家学习,交流
  • 相关阅读:
    初賽
    SA
    高斯-约旦消元法
    AC自动机
    KMP
    关于scanf
    网络流
    常用SQL语句
    Java开发中的23种设计模式详解(转)
    generatorConfig.xml
  • 原文地址:https://www.cnblogs.com/lijintao1025/p/10097247.html
Copyright © 2020-2023  润新知