0

so i use kafka to send messages and receive messages and when it successfully receive a message its going to cleanup tempory create topic and clear the group ids and the topic is going to delete but group id is not can anyone explain or help me

my code

    this.getData = function (exchangeName, eventData) {
      return new Promise(async (resolve, reject) => {
        const replyTopic = `reply_${exchangeName}_${uuidv4()}_${Date.now()}`;
        const consumerGroupId = `${replyTopic}_consumer`;
        const consumer = this.kafka.consumer({
          groupId: consumerGroupId,
        });
        const sender = this.kafka.producer();
        const admin = this.kafka.admin();

        await consumer.connect();
        await sender.connect();
        await admin.connect();

        await consumer.subscribe({
          topic: replyTopic,
          fromBeginning: false,
        });

        const cleanUp = async () => {
          await consumer.stop();
          await consumer.disconnect();
          await sender.disconnect();

          await admin.deleteTopics({
            topics: [replyTopic],
          });
          await admin.deleteGroups([consumerGroupId]);
          await admin.disconnect();
        };

        const timeout = setTimeout(
          () => {
            cleanUp();
            reject({
              exchangeName,
              message: "Request timed out",
              error: true,
            });
          },
          1000 * 60 * 10
        );
        await consumer.run({
          eachMessage: async ({ message }) => {
            clearTimeout(timeout);
            cleanUp();
            if (message.value) {
              resolve(CircularJSON.parse(message.value.toString()));
            }
          },
        });

        await sender.send({
          topic: exchangeName,
          messages: [
            {
              value: CircularJSON.stringify(eventData),
              headers: {
                replyTo: replyTopic,
              },
            },
          ],
        });
      });
    };

error message

4|index  | KafkaJSDeleteGroupsError: Error in DeleteGroups
4|index  |     at /root/ICT-Competition-Dashboard/User Panel/node_modules/kafkajs/src/admin/index.js:973:38
4|index  |     at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
4|index  |     at async cleanUp (/root/ICT-Competition-Dashboard/User Panel/src/structures/WebSite.js:163:11) {
4|index  |   retriable: true,
4|index  |   helpUrl: undefined,
4|index  |   groups: [
4|index  |     {
4|index  |       groupId: 'reply_getFile_f4f334a2-c798-4bba-b470-911a6dc6e766_1692118726039_consumer',
4|index  |       errorCode: 69,
4|index  |       error: [KafkaJSProtocolError]
4|index  |     }
4|index  |   ],
4|index  |   [cause]: undefined
4|index  | }`your text`

and also in the topic deletation i cannot do that on windows it throws a error called access denied and exits the kafka

0 Answers0