【发布时间】:2021-08-04 16:39:43
【问题描述】:
有没有办法通过发布/订阅模式使用 NestJS 微服务?例如与 amqp?据我了解,每个“微服务类型”都遵循请求/响应模式。
【问题讨论】:
有没有办法通过发布/订阅模式使用 NestJS 微服务?例如与 amqp?据我了解,每个“微服务类型”都遵循请求/响应模式。
【问题讨论】:
@EventPattern('user_created')
async handleUserCreated(data: Record<string, unknown>) {
// business logic
}
async publish() {
this.client.emit<number>('user_created', new UserCreatedEvent());
}
【讨论】:
上述解决方案不起作用。 看这里 https://github.com/nestjs/nest/issues/3981
根据 NestJs 文档,您有两种选择。
【讨论】: