MS-(A) 将数百条消息发送到 Azure 服务总线 - 主题,另一方面 MS-(B) 通过实现 AMQP 订阅接收这些消息
this.subscription = this.receiver.subscribe({
processMessage: this.onMessage,
processError: this.onError
});
async onMessage(message) {
await this.eventHandler(message)
}
public async eventHandler(message): Promise<void> {
console.log('before')
await Utilities.sleep(5000)
console.log('after')
}
结果是消息以同步方式而不是并行方式接收。这意味着在处理程序不发送响应之前,不会收到其他消息。我希望阅读更多消息,直到等待。
当前结果: 之前(等待 5 秒)之后
预期结果:之前之前……之后(5秒后)
如何实现它以便在另一个处于睡眠状态或换句话说作为并行模式时继续接收消息?