1

I have created a AWS Lambda function which should connect to given Kafka Topic and return the latest offset of it. But it is not working.

exports.handler = async (event, context) => {

var Client = kafka.KafkaClient;
var client = new Client({ kafkaHost: brokers });
var offs = new kafka.Offset(client);

var offst = 0;
const callbck = () => {
  return new Promise((resolve, reject) => {
    offs.fetch([{ topic: test_topic, partition: 0, time: -1 }], function (err, data) {
      if (err) {
        reject(err);
      }
      else {
        resolve(data[test_topic][0][0]);
      }
    })
  });
}

try {
    console.log("before callback");
    topic_msg_count = await callbck();
    console.log("after callback");
}
catch (error) {
  console.log(error);
}

}

but here this function is not going till second console.log "after callback" statement and getting timeout. tried even increasing time frame to 20-30 secs but still no luck, can someone please help me with it. What might be the issue here

0 Answers0