2

I'm using the Kafka JS to connect to kafka. In my consumer, initially I named my group id as 'orderable-test', later when I updated the this group id to 'orderable-test-1' and rerun my code, the group id remains the 'orderable-test'. Even if I comment out this consumer completely and write another consumer with a different group id in a different file, it still give me this 'orderable-test' as the group id instead of the new one. I would like to know what's the cause of it and how can I solve this.

Below is the code sample I wrote.

const consumer = kafka.consumer({ groupId: 'order-create-test' });
export class OrderInfoController {

  constructor(private readonly OrderInfoService: OrderInfoService) {}
   
  async onModuleInit() { 
    await consumer.connect();
    this.CreateOrderConsumer(consumer);
  }
  async onModuleDestroy() {
    await consumer.disconnect();
  }
  async CreateOrderConsumer(consumer){

    await consumer.subscribe({ topic: 'test-order', fromBeginning: true });
    await consumer.run({
      eachMessage: async ({ topic, partition, message }) => {
        console.log({
          topic, partition,
          message:{
          key: message.key.toString(),
          value: message.value.toString(),
        }})
        
      },
    });

  }
Zichzheng
  • 1,090
  • 7
  • 25

1 Answers1

1

I figured it out myself. I think for NestJS Kafka, the hot reload function doesn't work out well. When a Kafka Group ID is set, it seems it will be written into the node_module.

To solve this, I will need to delete the node_modules and the dist folder and do a npm install and npm rebuild to reflect my code change.

Zichzheng
  • 1,090
  • 7
  • 25