const { JSConsumer, JSProducer } = require("sinek");
const config = {
clientId: "my-app",
brokers: ["localhost:9092"],
};
async function run() {
const topic = "my-topic";
const producer = new JSProducer(config);
const consumer = new JSConsumer(topic, config);
producer.on("error", (error) => console.error(error));
consumer.on("error", (error) => console.error(error));
await consumer.connect();
// consume from a topic.
consumer.consume(async (messages) => {
messages.forEach((message) => {
console.log(message);
});
});
// Produce messages to a topic.
await producer.connect();
producer.send(topic, "a message");
}
run()
And it simply returns me this:
const { "metadata.broker.list": brokerList, "client.id": clientId, "security.protocol": securityProtocol, "ssl.ca.location": sslCALocation, "ssl.certificate.location": sslCertLocation, "ssl.key.location": sslKeyLocation, "ssl.key.password": sslKeyPassword, "sasl.mechanisms": mechanism, "sasl.username": username, "sasl.password": password, } = config.noptions;
^
TypeError: Cannot destructure property 'metadata.broker.list' of 'config.noptions' as it is undefined.
at new JSProducer (/home/arantes/tmp/kafka-test/node_modules/sinek/dist/lib/kafkajs/JSProducer.js:72:41)
at run (/home/arantes/tmp/kafka-test/test.js:11:20)
at Object.<anonymous> (/home/arantes/tmp/kafka-test/test.js:32:1)
at Module._compile (node:internal/modules/cjs/loader:1105:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Module._load (node:internal/modules/cjs/loader:827:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12)
at node:internal/main/run_main_module:17:47
Node.js v18.0.0
Tried the readme example:
And it simply returns me this: