【问题标题】:How to ensure the messages has been processed by all subscriptions in azure service bus如何确保消息已被 azure 服务总线中的所有订阅处理
【发布时间】:2018-07-12 08:04:36
【问题描述】:

由于 azure 服务总线对消息大小(256 kb)有限制,我将长消息存储在 blob 中,当函数应用收到消息时,我正在从 blob 存储下载内容并将其转换为消息格式。

服务总线成功处理消息后,我需要从 blob 存储中删除该文件,因为它不再需要。

但这里的问题是,同一主题下的两个订阅发送了相同的消息,一个由函数应用处理,另一个由 Web 作业处理。如果我从函数应用程序中的 blob 中删除文件,则 webjob 将无法使用该文件,反之亦然。

那么有什么方法可以识别出消息已经被所有订阅者成功处理了吗?

【问题讨论】:

  • 您能否为消息添加自定义属性?
  • 我不知道这里是否有“正确答案”,我可能会创建一个数据库/存储表,我会在其中标记完成,然后有一些计划的函数来检查该表并删除相关的 blob如果所有处理器都已完成。

标签: azure azure-blob-storage servicebus


【解决方案1】:

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.

我希望这对你有用。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-02-12
    • 2020-07-20
    • 2020-01-31
    • 1970-01-01
    • 1970-01-01
    • 2021-08-01
    • 1970-01-01
    相关资源
    最近更新 更多