rob3000 / nestjs-kafka

NestJS integration with KafkaJS
The Unlicense
130 stars 44 forks source link

Confusing documentation about payloads #21

Open maxgr0 opened 3 years ago

maxgr0 commented 3 years ago

When using the module as stated in the documentation, it's not possible to get other informations about the incoming kafka message. The documentation needs to be changed a bit because the consumers are get called different than when using the normal KafkaTransporter provided by NestJS. The @Payload decorator is not needed anyways. So when using the example from below, data would be the decoded message from Kafka without any more informations.

export class Consumer {
  constructor(
    @Inject('HERO_SERVICE') private client: KafkaService
  ) {}

  @SubscribeTo('hero.kill.dragon')
  async getWorld(@Payload() data: KafkaMessage): Promise<void> {
    ...
  }

}

https://github.com/rob3000/nestjs-kafka/blob/2c560e38e91b1e4994c6c13add47fb2f0b55f182/src/kafka.service.ts#L194-L202

Furthermore, as this module is about having no reply channels (comparing to the original KafkaTransporter) - why is the method

client.subscribeToResponseOf('hero.kill.dragon');

called in the examples?

Cheers!🚀