【发布时间】:2021-12-11 18:29:07
【问题描述】:
如果我在 NestJS 应用程序中使用 NATS 进行异步通信,是否可以手动确认消息?这是非常常见的用例,在服务处理完消息后确认消息。如果消息未被确认,服务器将需要重新传递(就像在旧的 NATS 流媒体库中一样)。
@EventPattern({ cmd: 'user:create' })
async createUser(@Payload() user: UserDto, @Ctx() context: NatsContext) {
await this.emailsService.sendWelcomeEmail(user)
// need to manually acknowledge the message here but the docs do not provide a way to do so.
}
【问题讨论】:
-
您的嵌套标签错误。如果你修复它,你可能会得到帮助。