2

我在 TypeScript 中使用本地的 KafkaJS 库,使用单个 kafka 代理。我已成功连接生产者,已验证我的主题已创建,并且正在生成消息:


  const changeMessage = {
    key: id,
    value: JSON.stringify(person),
    headers: {
      changeType: status,
    },
  };

现在当我去发送消息时:


  try {
    const sendResponse = await producer.send({
      topic: topicName2,
      messages: [changeMessage],
    });
    log.responseFragment(
      { id, topicName2 },
      `Sending changed/added person ${id} to topic ${topicName2}`
    );
  } catch (error) {
    log.error(
    { error }, `Could not send personChangedAdded ${id} to topic ${topicName2}`
    );
  }

这是我回来的错误:

Could not send personChange to topic topicName2
    error: {
      "name": "KafkaJSError",
      "retriable": true
    }
4

1 回答 1

0

我未能定义log.responseFragment(),当我将其更改为简单时log.info(),问题就解决了。

于 2021-08-17T19:27:22.697 回答