由于azure服务总线对消息大小(256 kb)有限制,因此我在blob中存储一条长消息,当函数应用程序收到消息时,我从blob存储下载内容并将其转换为消息格式。
服务总线成功处理消息后,我需要从 Blob 存储中删除该文件,因为不再需要它。
但这里的问题是,相同的消息已发送到同一主题下的两个订阅,一个由函数应用程序处理,另一个由 Web 作业处理。如果我从函数应用程序中的 blob 中删除该文件,则该文件将不可用于 webjob,反之亦然。
那么有什么方法可以识别该消息已被所有订阅者成功处理吗?
最佳答案
Azure Servicebus 消息传递为我们提供了一种添加 custom or user properties 的方法到服务总线消息。所以
1.You can add a custom property like messageReceptionCount to your message with initial value as 0 and send it to your topic.
2.While receiving the message in your topic subscription, you can increment the messageReceptionCount by 1.
3.When the messageReceptionCount has reached the number of subscriptions in the topic you can delete it from your blob storage.
我希望这对您有用。
关于azure - 如何确保Azure服务总线中的所有订阅都已处理消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51300336/