I am trying to emit a message to a kafka topic in the catch function, but the code is not work. here is my code:
constructor(@Inject('any') private readonly kfk: ClientKafka,private prisma: PrismaService,) {}
async Send(){
try {
await this.prisma.me.create({
data: {
Message:"test",
},
});
} catch (e) {
await this.kfk.emit('Notification.back', {
Me:"test",
})
}
}
The Message is string type. When I try to send a non-string Message to the database, it will have an error, and it should execute the code in the catch. However, this.kfk.emit is not working.
Please help