我在 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
}