为什么会出现错误`kafka.client`不是构造函数,同时在`npm kafka node`上这是创建kafka连接的方法?

2mbi3lxu  于 2021-06-04  发布在  Kafka
关注(0)|答案(1)|浏览(363)

为什么我会出错 kafka.Client 不是构造函数 npm kafka-node 这是创建Kafka连接的方法吗?
具体问题是: this.client = new kafka.Client(); 整个构造器是:

constructor(){
    this.Producer = kafka.Producer,
    this.client = new kafka.Client();
    this.producer = new Producer(client);
}
sy5wg1nm

sy5wg1nm1#

这个问题的解决办法如下。通过此实现,代码按预期工作:

constructor(){
        this.Producer = kafka.Producer,
        this.client = new kafka.KafkaClient();
        this.producer = new kafka.Producer(this.client);
}

相关问题