【Azure 存储服务】Azure Storage Account Queue中因数据格式无法处理而在一个小时内不在可见的问题
问题描述
在从Storage Account 队列中获取数据(Queue),在门户中,明显看见有数据,但是通过消费端代码去获取的时候,就是无法获取到有效数据的情况。获取消息的代码如下:
问题解答
经过对 receiveMessages 方法定义的查询,第二个参数,第三个参数的两个时间表示的意思为 消息在Queue中不可见的时间,和消息被处理的超时时间。如上段代码所示,当获取到消息后,如果10秒没有处理完消息,消息就会超时。但是因为第二个参数设置的是3600秒(1小时),所以它会有一个小时在Queue中不可见。
虽然问题中消息不能再10秒中处理完是因为数据格式的问题,获取的数据格式为JSON,但是下游系统需要处理的是Based64格式。但是第二个参数3600秒的设定是不合理。
最建议的参数值为:第二(visibilityTimeout),第三(timeout ) 参数的时间一样。
参考资料
public PagedIterable receiveMessages(Integer maxMessages, Duration visibilityTimeout, Duration timeout, Context context)
Retrieves up to the maximum number of messages from the queue and hides them from other operations for the timeout period.
Parameters:
maxMessages - Optional. Maximum number of messages to get, if there are less messages exist in the queue than requested all the messages will be returned. If left empty only 1 message will be retrieved, the allowed range is 1 to 32 messages.visibilityTimeout - Optional. The timeout period for how long the message is invisible in the queue. If left empty the received messages will be invisible for 30 seconds. The timeout must be between 1 second and 7 days.timeout - An optional timeout applied to the operation. If a response is not returned before the timeout concludes a RuntimeException will be thrown.context - Additional context that is passed through the Http pipeline during the service call.
当在复杂的环境中面临问题,格物之道需:浊而静之徐清,安以动之徐生。 云中,恰是如此!
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?
2021-12-16 【Azure 应用服务】App Service For Windows 中如何设置代理实现前端静态文件和后端Java Spring Boot Jar包
2020-12-16 【Azure Redis 缓存】Azure Redis 服务不支持指令CONFIG