【问题标题】:Azure servicebus listener on nestjsNestjs 上的 Azure 服务总线侦听器
【发布时间】:2021-12-26 14:07:06
【问题描述】:

我有一项服务可以处理我的产品的业务逻辑。

当我通过 azure 上的服务总线收到消息时,我需要调用该服务。

我可以使用 azure npm 包从 azure 服务总线队列中挑选消息。参考:https://docs.microsoft.com/en-us/azure/service-bus-messaging/service-bus-nodejs-how-to-use-queues

但是当消息到达我的应用程序时,我无法将业务逻辑类注入上述侦听器。我们正在使用 NestJS 框架。

技术细节:NestJS、NodeJs、Typescript、Azure 服务总线

【问题讨论】:

标签: node.js typescript azure nestjs azureservicebus


【解决方案1】:

Jesse-Carter 提供的发布建议作为答案,以便对面临类似问题的其他社区成员有所帮助。

NesBus(Nest / Service Bus)是 NestJS 的微服务扩展,它在 NestJS 中以简单且直观的方式。

消息处理

处理传入的服务总线消息现在就像处理传入的 REST 请求一样简单。

@Controller()

export  class  ServiceBusController  {

 @Queue<MethodDecorator>(({

 name:  'nesbus-queue.demo'

 })

 async  myQueueEntity(@Ctx()  context: SbContext)  {

 }

}

更多信息请查看NesBus

【讨论】:

  • 如果我的答案对您有帮助,您可以接受它作为答案(点击答案旁边的复选标记,将其从灰色切换为已填充。)。这对其他社区成员可能是有益的。谢谢
猜你喜欢
  • 1970-01-01
  • 2021-11-29
  • 2017-05-07
  • 2017-08-20
  • 2020-04-23
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2010-10-28
相关资源
最近更新 更多