Currently, I am using TypeScript and the KafkaJS library on my local machine with a single Kafka broker. After successfully connecting a producer, confirming the creation of my topic, and creating messages like so:
const changeMessage = {
key: id,
value: JSON.stringify(person),
headers: {
changeType: status,
},
};
However, when I attempt to send the message:
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}`
);
}
An error is encountered:
Could not send personChange to topic topicName2
error: {
"name": "KafkaJSError",
"retriable": true
}