azure - 如何确保消息已被 azure 服务总线中的所有订阅处理
问题描述
由于 azure 服务总线对消息大小(256 kb)有限制,我将一条长消息存储在 blob 中,当函数应用收到消息时,我正在从 blob 存储下载内容并将其转换为消息格式。
服务总线成功处理消息后,我需要从 blob 存储中删除该文件,因为它不再需要。
但这里的问题是,同一主题下的两个订阅发送了相同的消息,一个由函数应用处理,另一个由 Web 作业处理。如果我从函数应用程序中的 blob 中删除文件,则 webjob 将无法使用该文件,反之亦然。
那么有没有什么方法可以识别出消息已经被所有订阅者成功处理了呢?
解决方案
Azure 服务总线消息传递为我们提供了一种将自定义或用户属性添加到服务总线消息的方法。所以
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.
我希望这对你有用。
推荐阅读
- html - 我可以检查 CSS 中的一个属性是否等于另一个属性吗?
- c++ - 找不到 -lfreeglut 代码块
- c# - 多个实例中的相同 IHostedService
- flutter - 无法解析配置“:app:debugRuntimeClasspath”的所有文件。,颤动
- php - cakephp 3 中动态下拉列表的问题
- java - 在连接四中检查获胜者 - Kotlin
- android - Android Kotlin - 房间本地存储,构建错误“执行 org.jetbrains.kotlin.gradle.internal.KaptExecution 时发生故障”
- mysql - VB.net 如果某个值不符合 Mysql 的要求,请检查下一行
- python - 使用多处理和线程并行处理非常大的文本文件
- javascript - 在角度拦截器中设置 cookie