I am looking for an example to use NestJS Kafka microservice work with Avro schema.
So far the consumers are working with Json Object but we are looking to towards schema registry with Avro as schema type.
Kafka Config:
transport: Transport.KAFKA,
options: {
client: {
clientId,
ssl: true,
brokers,
},
consumer: {
groupId: consumerGroupId,
},
subscribe: {
fromBeginning: false,
},
},
};
Consumer:
@Controller(USER)
@UseInterceptors(ClassSerializerInterceptor)
export class UserController {
constructor(private readonly service: UserService) {
}
@EventPattern(process.env.USER_TOPIC, Transport.KAFKA)
async processUserEvent(data: UserEvent) {
await this.service.handleEvent(data);
}
}