gpt4 book ai didi

Azure 存储队列客户端不会将消息放入有害队列中

转载 作者:行者123 更新时间:2023-12-03 07:09:14 24 4
gpt4 key购买 nike

这是一个新手问题。

我有一个使用存储队列 (Client.Azure.Storage.Queues) 的计时器触发器

客户端是否自动将未处理的消息发送到病毒队列?这段代码模拟了一个错误。如果一切正常,则该消息将被删除。

        public async Task Run([TimerTrigger("%TimerExpression%")]TimerInfo myTimer, ILogger log)
{
log.LogInformation($"C# Timer trigger function executed at: {DateTime.Now}");

QueueMessage[] messages = await _queueClient.ReceiveMessagesAsync(maxMessages: 10, null );

try
{
foreach (QueueMessage message in messages)
{
Console.WriteLine(message.DequeueCount + "-------------------");
Console.WriteLine (message.Body)=
_queueClient.(message);
throw new ApplicationException("HELP");

_queueClient.DeleteMessage(message.MessageId, message.PopReceipt);

}
}
catch(Exception e)
{
Console.WriteLine(e.Message);
}

}

我希望重试 2 次后消息不会返回到队列:

{
"version": "2.0",
"logging": {
"applicationInsights": {
"samplingSettings": {
"isEnabled": true,
"excludedTypes": "Request"
}
}
},
"extensions": {
"queues": {
"retry": {
"strategy": "fixedDelay",
"maxRetryCount": 2,
"delayInterval": "00:00:03"
}
}
}
}

或者我错过了什么?或者我必须手动将消息添加到有害队列中吗?

问候斯特凡

最佳答案

Does the client automatically send not processed messages to the poison queue?

不,事实并非如此。

但是,Azure Functions 队列触发器将。如果您从队列而不是计时器触发函数,那么您最终会收到有害队列消息。

如果您直接使用存储客户端并且不触发队列,那么您需要执行自己的有害队列处理。

关于Azure 存储队列客户端不会将消息放入有害队列中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70774172/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com