I have a kafka application running on docker, and I have my nestjs app as microserver, I would like to have a route that takes all the existing messages from a topic inside the kafka broker, is there a way?
Below is my nestjs code, if you can help me implement how I get them
import { Controller, Get, OnApplicationShutdown } from "@nestjs/common";
import { EventPattern, MessagePattern, Payload, } from "@nestjs/microservices";
import { Consumer, ConsumerRunConfig, ConsumerSubscribeTopics, Kafka } from "kafkajs";
@Controller('/kafka')
export class KafkaEventController {
private readonly kafka = new Kafka({
brokers: ['localhost:29092']
}).producer()
private adminKafka: Kafka
@Get('getmessages')
public async getConsumers (): Promise<any> {
}
@MessagePattern('Cart')
public async sincronize (@Payload() payload: any): Promise<void> {
}
}